dudley/src/NodeMapping.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_NODEMAPPING_H__
#define __DUDLEY_NODEMAPPING_H__
#include "Util.h"
namespace dudley {
struct NodeMapping
{
NodeMapping() : numNodes(0), target(NULL), numTargets(0), map(NULL) {}
void clear()
{
delete[] map;
delete[] target;
target = NULL;
map = NULL;
numNodes = 0;
numTargets = 0;
}
void assign(const index_t* theTarget, dim_t nNodes, index_t unused)
{
clear();
if (nNodes == 0)
return;
numNodes = nNodes;
std::pair<index_t,index_t> range(
util::getFlaggedMinMaxInt(numNodes, theTarget, unused));
if (range.first < 0) {
throw escript::ValueError("NodeMapping: target has negative entry.");
}
numTargets = range.first<=range.second ? range.second+1 : 0;
target = new index_t[numNodes];
map = new index_t[numTargets];
bool err = false;
#pragma omp parallel
{
#pragma omp for
for (index_t i=0; i<numNodes; ++i) {
target[i] = theTarget[i];
if (target[i] != unused)
map[target[i]] = i;
}
// sanity check
#pragma omp for
for (index_t i=0; i<numTargets; ++i) {
if (map[i] == -1) {
#pragma omp critical
err = true;
}
}
}
if (err)
throw escript::ValueError("NodeMapping: target does not define a continuous labeling.");
}
inline dim_t getNumTargets() const { return numTargets; }
dim_t numNodes;
index_t* target;
dim_t numTargets;
index_t* map;
};
} // namespace dudley
#endif // __DUDLEY_NODEMAPPING_H__
dudley::NodeFile::globalDegreesOfFreedom
index_t * globalDegreesOfFreedom
Definition: dudley/src/NodeFile.h:157
MPI_Status
int MPI_Status
Definition: EsysMPI.h:45
dudley::NodeFile::gather
void gather(const index_t *index, const NodeFile *in)
Definition: NodeFile_gather.cpp:77
escript::DataTypes::real_t
double real_t
type of all real-valued scalars in escript
Definition: DataTypes.h:79
dudley::NodeMapping::numTargets
dim_t numTargets
size of map (number of target nodes, e.g. DOF, reduced DOF, etc.)
Definition: dudley/src/NodeMapping.h:124
dudley::NodeFile::nodesDistribution
escript::Distribution_ptr nodesDistribution
MPI distribution of nodes.
Definition: dudley/src/NodeFile.h:164
dudley::NodeFile::numDim
int numDim
number of spatial dimensions
Definition: dudley/src/NodeFile.h:146
dudley::NodeMapping::assign
void assign(const index_t *theTarget, dim_t nNodes, index_t unused)
Definition: dudley/src/NodeMapping.h:73
dudley::NodeFile
Definition: dudley/src/NodeFile.h:39
DudleyDomain.h
dudley::NodeFile::createNodeMappings
void createNodeMappings(const IndexVector &dofDistribution, const IndexVector &nodeDistribution)
Definition: NodeFile_createMappings.cpp:238
dudley::NodeFile::createDOFMappingAndCoupling
void createDOFMappingAndCoupling()
Definition: NodeFile_createMappings.cpp:43
escript::DataTypes::index_t_min
index_t index_t_min()
Returns the minimum finite value for the index_t type.
Definition: DataTypes.h:99
INDEX2
#define INDEX2(_X1_, _X2_, _N1_)
Definition: index.h:23
dudley::gatherEntries
static void gatherEntries(dim_t n, const index_t *index, index_t min_index, index_t max_index, index_t *Id_out, const index_t *Id_in, int *Tag_out, const int *Tag_in, index_t *globalDegreesOfFreedom_out, const index_t *globalDegreesOfFreedom_in, int numDim, real_t *Coordinates_out, const real_t *Coordinates_in)
Definition: NodeFile_gather.cpp:27
dudley::NodeMapping::getNumTargets
dim_t getNumTargets() const
returns the number of target nodes (number of items in the map array)
Definition: dudley/src/NodeMapping.h:115
dudley::scatterEntries
static void scatterEntries(dim_t n, const index_t *index, index_t min_index, index_t max_index, index_t *Id_out, const index_t *Id_in, int *Tag_out, const int *Tag_in, index_t *globalDegreesOfFreedom_out, const index_t *globalDegreesOfFreedom_in, int numDim, real_t *Coordinates_out, const real_t *Coordinates_in)
Definition: NodeFile_gather.cpp:52
MPI_SUM
#define MPI_SUM
Definition: EsysMPI.h:52
dudley::NodeFile::createDenseDOFLabeling
dim_t createDenseDOFLabeling()
Definition: NodeFile_createDenseLabelings.cpp:36
paso::SharedComponents
Definition: SharedComponents.h:55
dudley::NodeFile::MPIInfo
escript::JMPI MPIInfo
MPI information.
Definition: dudley/src/NodeFile.h:144
dudley::NodeFile::getGlobalIdRange
std::pair< index_t, index_t > getGlobalIdRange() const
Definition: dudley/src/NodeFile.cpp:171
escript::checkResult
bool checkResult(int res, int &mres, const JMPI &info)
Everyone puts in their error code and everyone gets the largest one.
Definition: EsysMPI.cpp:124
dudley::NodeFile::nodesMapping
NodeMapping nodesMapping
Definition: dudley/src/NodeFile.h:131
dudley::NodeFile::getGlobalDOFRange
std::pair< index_t, index_t > getGlobalDOFRange() const
Definition: dudley/src/NodeFile.cpp:176
paso::Connector
Definition: Coupler.h:61
dudley::NodeFile::status
int status
Definition: dudley/src/NodeFile.h:177
escript::Distribution
Definition: Distribution.h:46
MPI_INT
#define MPI_INT
Definition: EsysMPI.h:46
escript::DataTypes::index_t_max
index_t index_t_max()
Returns the maximum finite value for the index_t type.
Definition: DataTypes.h:108
MPI_MAX
#define MPI_MAX
Definition: EsysMPI.h:54
dudley
A suite of factory methods for creating 2D and 3D dudley domains.
Definition: dudley/src/Assemble.h:32
dudley::util::getFlaggedMinMaxInt
IndexPair getFlaggedMinMaxInt(dim_t N, const index_t *values, index_t ignore)
Definition: dudley/src/Util.cpp:214
dudley::NodeMapping::numNodes
dim_t numNodes
size of target (number of FEM nodes)
Definition: dudley/src/NodeMapping.h:118
escript::DataTypes::dim_t
index_t dim_t
Definition: DataTypes.h:93
dudley::NodeFile::degreesOfFreedomMapping
NodeMapping degreesOfFreedomMapping
Definition: dudley/src/NodeFile.h:132
dudley::NodeFile::gather_global
void gather_global(const index_t *index, const NodeFile *in)
Definition: NodeFile_gather.cpp:85
dudley::NodeFile::createDenseNodeLabeling
dim_t createDenseNodeLabeling(IndexVector &nodeDistribution, const IndexVector &dofDistribution)
escript::AssertException
An exception class for assertions within escript.
Definition: EsysException.h:73
dudley::NodeMapping::target
index_t * target
target[i] defines the target of FEM node i=0,...,numNodes
Definition: dudley/src/NodeMapping.h:121
NodeFile.h
paso::SharedComponents_ptr
boost::shared_ptr< SharedComponents > SharedComponents_ptr
Definition: SharedComponents.h:50
MPI_DOUBLE
#define MPI_DOUBLE
Definition: EsysMPI.h:47
dudley::NodeMapping::map
index_t * map
maps the target nodes back to the FEM nodes: target[map[i]]=i
Definition: dudley/src/NodeMapping.h:127
escript::DataTypes::index_t
int index_t
type for array/matrix indices used both globally and on each rank
Definition: DataTypes.h:88
dudley::NodeMapping::NodeMapping
NodeMapping()
Definition: dudley/src/NodeMapping.h:57
dudley::NodeFile::dofDistribution
escript::Distribution_ptr dofDistribution
MPI distribution of degrees of freedom.
Definition: dudley/src/NodeFile.h:167
Util.h
dudley::NodeFile::Id
index_t * Id
Id[i] is the unique ID number of FEM node i.
Definition: dudley/src/NodeFile.h:148
dudley::NodeFile::Tag
int * Tag
Tag[i] is the tag of node i.
Definition: dudley/src/NodeFile.h:150
dudley::NodeFile::numNodes
dim_t numNodes
number of nodes
Definition: dudley/src/NodeFile.h:135
escript::shipString
bool shipString(const char *src, char **dest, MPI_Comm &comm)
Definition: EsysMPI.cpp:178
dudley::NodeFile::degreesOfFreedomId
index_t * degreesOfFreedomId
Definition: dudley/src/NodeFile.h:173
ESYS_ASSERT
#define ESYS_ASSERT(a, b)
EsysAssert is a MACRO that will throw an exception if the boolean condition specified is false.
Definition: Assert.h:79
dudley::NodeFile::Coordinates
double * Coordinates
Coordinates[INDEX2(k,i,numDim)] is the k-th coordinate of node i.
Definition: dudley/src/NodeFile.h:159
escript::ValueError
An exception class that signals an invalid argument value.
Definition: EsysException.h:103
dudley::NodeMapping::clear
void clear()
resets both map and target
Definition: dudley/src/NodeMapping.h:60
dudley::NodeFile::globalNodesIndex
index_t * globalNodesIndex
assigns each local node a global unique ID in a dense labeling
Definition: dudley/src/NodeFile.h:161
escript::DataTypes::IndexVector
std::vector< index_t > IndexVector
Definition: DataTypes.h:91