escript  Revision_
Util.h
Go to the documentation of this file.
00001 
00002 /*****************************************************************************
00003 *
00004 * Copyright (c) 2003-2014 by University of Queensland
00005 * http://www.uq.edu.au
00006 *
00007 * Primary Business: Queensland, Australia
00008 * Licensed under the Open Software License version 3.0
00009 * http://www.opensource.org/licenses/osl-3.0.php
00010 *
00011 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
00012 * Development 2012-2013 by School of Earth Sciences
00013 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
00014 *
00015 *****************************************************************************/
00016 
00017 
00018 /****************************************************************************
00019 
00020   Some utility routines
00021 
00022 *****************************************************************************/
00023 
00024 #ifndef __FINLEY_UTIL_H__
00025 #define __FINLEY_UTIL_H__
00026 
00027 #include "Finley.h"
00028 
00029 #include <escript/Data.h>
00030 
00031 namespace finley {
00032 namespace util {
00033 
00034 typedef std::vector< std::pair<int,int> > ValueAndIndexList;
00035 
00039 void sortValueAndIndex(ValueAndIndexList& array);
00040 
00042 inline bool hasReducedIntegrationOrder(const escript::Data& in)
00043 {
00044     const int fs = in.getFunctionSpace().getTypeCode();
00045     return (fs == FINLEY_REDUCED_ELEMENTS || fs == FINLEY_REDUCED_FACE_ELEMENTS
00046                 || fs == FINLEY_REDUCED_CONTACT_ELEMENTS_1
00047                 || fs == FINLEY_REDUCED_CONTACT_ELEMENTS_2);
00048 }
00049 
00050 void gather(int len, const int* index, int numData, const double* in,
00051             double* out);
00052 
00053 void addScatter(int len, const int* index, int numData, const double* in,
00054                 double* out, int upperBound);
00055 
00056 void smallMatMult(int A1, int A2, double* A, int B2,
00057                   const std::vector<double>& B,
00058                   const std::vector<double>& C);
00059 
00060 void smallMatSetMult1(int len, int A1, int A2, double* A, int B2,
00061                       const std::vector<double>& B,
00062                       const std::vector<double>& C);
00063 
00064 void invertSmallMat(int len, int dim, const double* A, double *invA,
00065                     double* det);
00066 
00067 void normalVector(int len, int dim, int dim1, const double* A, double* Normal);
00068 
00069 int getMinInt(int dim, int N, const int* values);
00070 
00071 int getMaxInt(int dim, int N, const int* values);
00072 
00073 std::pair<int,int> getMinMaxInt(int dim, int N, const int* values);
00074 
00075 std::pair<int,int> getFlaggedMinMaxInt(int N, const int* values, int ignore);
00076 
00077 std::vector<int> packMask(const std::vector<short>& mask);
00078 
00079 void setValuesInUse(const int *values, const int numValues,
00080                     std::vector<int>& valuesInUse, Esys_MPIInfo* mpiinfo);
00081 
00082 } // namespace util
00083 } // namespace finley
00084 
00085 #endif // __FINLEY_UTIL_H__
00086