finley/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 __FINLEY_NODEFILE_H__
#define __FINLEY_NODEFILE_H__
#define MAX_numDim 3
#include "Finley.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 finley {
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 index_t getFirstReducedNode() const;
inline index_t getLastReducedNode() const;
inline index_t getGlobalNumReducedNodes() const;
inline const index_t* borrowGlobalReducedNodesIndex() const;
inline dim_t getNumNodes() const;
inline dim_t getNumReducedNodes() const;
inline dim_t getNumDegreesOfFreedom() const;
inline dim_t getNumReducedDegreesOfFreedom() const;
inline dim_t getNumDegreesOfFreedomTargets() const;
inline dim_t getNumReducedDegreesOfFreedomTargets() const;
inline const IndexVector& borrowReducedNodesTarget() const;
inline const IndexVector& borrowDegreesOfFreedomTarget() const;
inline const IndexVector& borrowNodesTarget() const;
inline const IndexVector& borrowReducedDegreesOfFreedomTarget() const;
inline const index_t* borrowTargetReducedNodes() const;
inline const index_t* borrowTargetDegreesOfFreedom() const;
inline const index_t* borrowTargetNodes() const;
inline const index_t* borrowTargetReducedDegreesOfFreedom() const;
inline void updateTagList();
dim_t createDenseDOFLabeling();
dim_t createDenseNodeLabeling(IndexVector& nodeDistribution,
const IndexVector& dofDistribution);
dim_t createDenseReducedLabeling(const std::vector<short>& reducedMask,
bool useNodes);
void createNodeMappings(const IndexVector& indexReducedNodes,
const IndexVector& dofDistribution,
const IndexVector& nodeDistribution);
void assignMPIRankToDOFs(std::vector<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 scatter(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;
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(bool reduced);
NodeMapping nodesMapping;
NodeMapping degreesOfFreedomMapping;
NodeMapping reducedDegreesOfFreedomMapping;
dim_t numNodes;
public:
// these should be private as well.
NodeMapping reducedNodesMapping;
escript::JMPI MPIInfo;
int numDim;
index_t* Id;
int* Tag;
std::vector<int> tagsInUse;
index_t* globalDegreesOfFreedom;
double* Coordinates;
index_t* globalReducedDOFIndex;
index_t* globalReducedNodesIndex;
index_t* globalNodesIndex;
escript::Distribution_ptr nodesDistribution;
escript::Distribution_ptr reducedNodesDistribution;
escript::Distribution_ptr degreesOfFreedomDistribution;
escript::Distribution_ptr reducedDegreesOfFreedomDistribution;
#ifdef ESYS_HAVE_PASO
paso::Connector_ptr degreesOfFreedomConnector;
paso::Connector_ptr reducedDegreesOfFreedomConnector;
#endif
#ifdef ESYS_HAVE_TRILINOS
esys_trilinos::const_TrilinosMap_ptr trilinosRowMap;
esys_trilinos::const_TrilinosMap_ptr trilinosReducedRowMap;
esys_trilinos::const_TrilinosMap_ptr trilinosColMap;
esys_trilinos::const_TrilinosMap_ptr trilinosReducedColMap;
#endif
// these are the packed versions of Id
index_t* reducedNodesId;
index_t* degreesOfFreedomId;
index_t* reducedDegreesOfFreedomId;
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 index_t NodeFile::getFirstReducedNode() const
{
return reducedNodesDistribution->getFirstComponent();
}
inline index_t NodeFile::getLastReducedNode() const
{
return reducedNodesDistribution->getLastComponent();
}
inline dim_t NodeFile::getGlobalNumReducedNodes() const
{
return reducedNodesDistribution->getGlobalNumComponents();
}
inline const index_t* NodeFile::borrowGlobalReducedNodesIndex() const
{
return globalReducedNodesIndex;
}
inline dim_t NodeFile::getNumNodes() const
{
return numNodes;
}
inline dim_t NodeFile::getNumReducedNodes() const
{
return reducedNodesMapping.getNumTargets();
}
inline dim_t NodeFile::getNumDegreesOfFreedom() const
{
return degreesOfFreedomDistribution->getMyNumComponents();
}
inline dim_t NodeFile::getNumReducedDegreesOfFreedom() const
{
return reducedDegreesOfFreedomDistribution->getMyNumComponents();
}
inline dim_t NodeFile::getNumDegreesOfFreedomTargets() const
{
return degreesOfFreedomMapping.getNumTargets();
}
inline dim_t NodeFile::getNumReducedDegreesOfFreedomTargets() const
{
return reducedDegreesOfFreedomMapping.getNumTargets();
}
inline const IndexVector& NodeFile::borrowNodesTarget() const
{
return nodesMapping.map;
}
inline const IndexVector& NodeFile::borrowReducedNodesTarget() const
{
return reducedNodesMapping.map;
}
inline const IndexVector& NodeFile::borrowDegreesOfFreedomTarget() const
{
return degreesOfFreedomMapping.map;
}
inline const IndexVector& NodeFile::borrowReducedDegreesOfFreedomTarget() const
{
return reducedDegreesOfFreedomMapping.map;
}
inline const index_t* NodeFile::borrowTargetNodes() const
{
return &nodesMapping.target[0];
}
inline const index_t* NodeFile::borrowTargetReducedNodes() const
{
return &reducedNodesMapping.target[0];
}
inline const index_t* NodeFile::borrowTargetDegreesOfFreedom() const
{
return &degreesOfFreedomMapping.target[0];
}
inline const index_t* NodeFile::borrowTargetReducedDegreesOfFreedom() const
{
return &reducedDegreesOfFreedomMapping.target[0];
}
inline void NodeFile::updateTagList()
{
util::setValuesInUse(Tag, numNodes, tagsInUse, MPIInfo);
}
} // namespace finley
#endif // __FINLEY_NODEFILE_H__
Finley.h
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:64
finley::NodeFile
Definition: finley/src/NodeFile.h:42
finley::NodeFile::getGlobalDOFRange
std::pair< index_t, index_t > getGlobalDOFRange() const
Definition: finley/src/NodeFile.cpp:231
finley::NodeFile::getNumReducedNodes
dim_t getNumReducedNodes() const
returns the number of reduced order FEM nodes (on this rank)
Definition: finley/src/NodeFile.h:261
finley::NodeFile::Coordinates
double * Coordinates
Coordinates[INDEX2(k,i,numDim)] is the k-th coordinate of node i.
Definition: finley/src/NodeFile.h:175
finley::NodeFile::~NodeFile
~NodeFile()
destructor
Definition: finley/src/NodeFile.cpp:122
finley::NodeFile::updateTagList
void updateTagList()
Definition: finley/src/NodeFile.h:326
finley::NodeFile::reducedNodesMapping
NodeMapping reducedNodesMapping
Definition: finley/src/NodeFile.h:157
finley::NodeFile::getLastReducedNode
index_t getLastReducedNode() const
Definition: finley/src/NodeFile.h:241
finley::NodeFile::copyTable
void copyTable(index_t offset, index_t idOffset, index_t dofOffset, const NodeFile *in)
Definition: finley/src/NodeFile.cpp:285
finley::NodeFile::borrowTargetReducedDegreesOfFreedom
const index_t * borrowTargetReducedDegreesOfFreedom() const
Definition: finley/src/NodeFile.h:321
finley::NodeFile::createDOFMappingAndCoupling
void createDOFMappingAndCoupling(bool reduced)
Definition: finley/src/NodeFile.cpp:772
finley::NodeFile::getNumDegreesOfFreedomTargets
dim_t getNumDegreesOfFreedomTargets() const
returns the number of degrees of freedom targets (own and shared)
Definition: finley/src/NodeFile.h:276
finley::NodeFile::globalNodesIndex
index_t * globalNodesIndex
assigns each local node a global unique ID in a dense labeling
Definition: finley/src/NodeFile.h:183
finley::NodeFile::getGlobalNumReducedNodes
index_t getGlobalNumReducedNodes() const
Definition: finley/src/NodeFile.h:246
finley::NodeFile::freeTable
void freeTable()
empties the node table and frees all memory
Definition: finley/src/NodeFile.cpp:162
finley::NodeFile::globalReducedNodesIndex
index_t * globalReducedNodesIndex
Definition: finley/src/NodeFile.h:181
finley::NodeFile::degreesOfFreedomDistribution
escript::Distribution_ptr degreesOfFreedomDistribution
Definition: finley/src/NodeFile.h:188
finley::NodeFile::gather
void gather(const index_t *index, const NodeFile *in)
Definition: finley/src/NodeFile.cpp:321
finley::NodeFile::createDenseDOFLabeling
dim_t createDenseDOFLabeling()
Definition: finley/src/NodeFile.cpp:525
finley::NodeFile::globalDegreesOfFreedom
index_t * globalDegreesOfFreedom
Definition: finley/src/NodeFile.h:173
finley::NodeFile::MPIInfo
escript::JMPI MPIInfo
MPI information.
Definition: finley/src/NodeFile.h:160
finley::NodeFile::borrowGlobalReducedNodesIndex
const index_t * borrowGlobalReducedNodesIndex() const
Definition: finley/src/NodeFile.h:251
finley::NodeFile::allocTable
void allocTable(dim_t numNodes)
allocates the node table within this node file to hold numNodes nodes.
Definition: finley/src/NodeFile.cpp:127
finley::NodeFile::status
int status
Definition: finley/src/NodeFile.h:209
finley::NodeFile::globalReducedDOFIndex
index_t * globalReducedDOFIndex
Definition: finley/src/NodeFile.h:178
finley::NodeFile::reducedNodesDistribution
escript::Distribution_ptr reducedNodesDistribution
Definition: finley/src/NodeFile.h:187
finley::NodeFile::getGlobalIdRange
std::pair< index_t, index_t > getGlobalIdRange() const
Definition: finley/src/NodeFile.cpp:226
finley::NodeFile::getFirstNode
index_t getFirstNode() const
Definition: finley/src/NodeFile.h:216
finley::NodeFile::createDenseNodeLabeling
dim_t createDenseNodeLabeling(IndexVector &nodeDistribution, const IndexVector &dofDistribution)
Definition: finley/src/NodeFile.cpp:588
finley::NodeFile::print
void print() const
Definition: finley/src/NodeFile.cpp:196
finley::NodeFile::getGlobalNodeIDIndexRange
std::pair< index_t, index_t > getGlobalNodeIDIndexRange() const
Definition: finley/src/NodeFile.cpp:236
finley::NodeFile::getGlobalNumNodes
dim_t getGlobalNumNodes() const
Definition: finley/src/NodeFile.h:226
finley::NodeFile::reducedDegreesOfFreedomDistribution
escript::Distribution_ptr reducedDegreesOfFreedomDistribution
Definition: finley/src/NodeFile.h:189
finley::NodeFile::getFirstReducedNode
index_t getFirstReducedNode() const
Definition: finley/src/NodeFile.h:236
finley::NodeFile::degreesOfFreedomMapping
NodeMapping degreesOfFreedomMapping
Definition: finley/src/NodeFile.h:147
finley::NodeFile::NodeFile
NodeFile(int nDim, escript::JMPI MPIInfo)
Definition: finley/src/NodeFile.cpp:104
finley::NodeFile::getLastNode
index_t getLastNode() const
Definition: finley/src/NodeFile.h:221
finley::NodeFile::borrowDegreesOfFreedomTarget
const IndexVector & borrowDegreesOfFreedomTarget() const
Definition: finley/src/NodeFile.h:296
finley::NodeFile::borrowNodesTarget
const IndexVector & borrowNodesTarget() const
Definition: finley/src/NodeFile.h:286
finley::NodeFile::scatter
void scatter(const index_t *index, const NodeFile *in)
Definition: finley/src/NodeFile.cpp:310
finley::NodeFile::getNumReducedDegreesOfFreedom
dim_t getNumReducedDegreesOfFreedom() const
returns the number of reduced order degrees of freedom (on this rank)
Definition: finley/src/NodeFile.h:271
finley::NodeFile::getNumDegreesOfFreedom
dim_t getNumDegreesOfFreedom() const
returns the number of degrees of freedom (on this rank)
Definition: finley/src/NodeFile.h:266
finley::NodeFile::degreesOfFreedomId
index_t * degreesOfFreedomId
Definition: finley/src/NodeFile.h:204
finley::NodeFile::setCoordinates
void setCoordinates(const escript::Data &newX)
copies the array newX into this->coordinates
Definition: finley/src/NodeFile.cpp:242
finley::NodeFile::createNodeMappings
void createNodeMappings(const IndexVector &indexReducedNodes, const IndexVector &dofDistribution, const IndexVector &nodeDistribution)
Definition: finley/src/NodeFile.cpp:1004
finley::NodeFile::reducedDegreesOfFreedomMapping
NodeMapping reducedDegreesOfFreedomMapping
Definition: finley/src/NodeFile.h:148
finley::NodeFile::createDenseReducedLabeling
dim_t createDenseReducedLabeling(const std::vector< short > &reducedMask, bool useNodes)
Definition: finley/src/NodeFile.cpp:702
finley::NodeFile::nodesMapping
NodeMapping nodesMapping
Definition: finley/src/NodeFile.h:146
finley::NodeFile::Tag
int * Tag
Tag[i] is the tag of node i.
Definition: finley/src/NodeFile.h:166
finley::NodeFile::borrowReducedDegreesOfFreedomTarget
const IndexVector & borrowReducedDegreesOfFreedomTarget() const
Definition: finley/src/NodeFile.h:301
finley::NodeFile::borrowTargetReducedNodes
const index_t * borrowTargetReducedNodes() const
Definition: finley/src/NodeFile.h:311
finley::NodeFile::reducedDegreesOfFreedomId
index_t * reducedDegreesOfFreedomId
Definition: finley/src/NodeFile.h:205
finley::NodeFile::getNumReducedDegreesOfFreedomTargets
dim_t getNumReducedDegreesOfFreedomTargets() const
returns the number of reduced degrees of freedom targets (own and shared)
Definition: finley/src/NodeFile.h:281
finley::NodeFile::reducedNodesId
index_t * reducedNodesId
Definition: finley/src/NodeFile.h:203
finley::NodeFile::numNodes
dim_t numNodes
number of nodes
Definition: finley/src/NodeFile.h:151
finley::NodeFile::assignMPIRankToDOFs
void assignMPIRankToDOFs(std::vector< int > &mpiRankOfDOF, const IndexVector &distribution)
Definition: finley/src/NodeFile.cpp:438
finley::NodeFile::borrowTargetNodes
const index_t * borrowTargetNodes() const
returns the mapping from local nodes to a target
Definition: finley/src/NodeFile.h:306
finley::NodeFile::borrowTargetDegreesOfFreedom
const index_t * borrowTargetDegreesOfFreedom() const
Definition: finley/src/NodeFile.h:316
finley::NodeFile::borrowReducedNodesTarget
const IndexVector & borrowReducedNodesTarget() const
Definition: finley/src/NodeFile.h:291
finley::NodeFile::borrowGlobalNodesIndex
const index_t * borrowGlobalNodesIndex() const
Definition: finley/src/NodeFile.h:231
finley::NodeFile::prepareLabeling
dim_t prepareLabeling(const std::vector< short > &mask, IndexVector &buffer, IndexVector &distribution, bool useNodes)
Definition: finley/src/NodeFile.cpp:464
finley::NodeFile::Id
index_t * Id
Id[i] is the unique ID number of FEM node i.
Definition: finley/src/NodeFile.h:164
finley::NodeFile::setTags
void setTags(int newTag, const escript::Data &mask)
set tags to newTag where mask > 0
Definition: finley/src/NodeFile.cpp:267
finley::NodeFile::gather_global
void gather_global(const index_t *index, const NodeFile *in)
Definition: finley/src/NodeFile.cpp:329
finley::NodeFile::getDOFRange
std::pair< index_t, index_t > getDOFRange() const
Definition: finley/src/NodeFile.cpp:215
finley::NodeFile::getNumNodes
dim_t getNumNodes() const
returns the number of FEM nodes (on this rank)
Definition: finley/src/NodeFile.h:256
finley::NodeFile::numDim
int numDim
number of spatial dimensions
Definition: finley/src/NodeFile.h:162
finley::NodeFile::tagsInUse
std::vector< int > tagsInUse
vector of tags which are actually used
Definition: finley/src/NodeFile.h:168
finley::NodeFile::nodesDistribution
escript::Distribution_ptr nodesDistribution
MPI distribution of nodes.
Definition: finley/src/NodeFile.h:186
NodeMapping.h
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
finley::util::setValuesInUse
void setValuesInUse(const int *values, dim_t numValues, std::vector< int > &valuesInUse, escript::JMPI mpiinfo)
Definition: finley/src/Util.cpp:343
finley
A suite of factory methods for creating various finley domains.
Definition: finley/src/Assemble.h:32
paso::Connector_ptr
boost::shared_ptr< Connector > Connector_ptr
Definition: Coupler.h:38
finley::NodeMapping
Definition: finley/src/NodeMapping.h:30
finley::NodeMapping::target
std::vector< index_t > target
target[i] defines the target of FEM node i=0,...,numNodes-1
Definition: finley/src/NodeMapping.h:82
finley::NodeMapping::map
std::vector< index_t > map
maps the target nodes back to the FEM nodes: target[map[i]]=i
Definition: finley/src/NodeMapping.h:84
finley::NodeMapping::getNumTargets
dim_t getNumTargets() const
returns the number of target nodes (number of items in the map array)
Definition: finley/src/NodeMapping.h:79