SET(ADD_WERROR OFF)
ENDIF(X${VAL} STREQUAL X1)
ENDFOREACH(name ${NAMES})
- IF(ADD_WERROR)
- SET(CMAKE_C_FLAGS "-Werror")
- SET(CMAKE_CXX_FLAGS "-Werror")
- ENDIF(ADD_WERROR)
+# IF(ADD_WERROR)
+# SET(CMAKE_C_FLAGS "-Werror")
+# SET(CMAKE_CXX_FLAGS "-Werror")
+# ENDIF(ADD_WERROR)
ENDIF(WINDOWS)
IF(CMAKE_BUILD_TYPE)
#---------------------------------------------------------------------------
INPUT = @builddir@ \
@srcdir@ \
+ @srcdir@/fakesources \
@srcdir@/../../src/ParaMEDMEM \
@srcdir@/../../src/INTERP_KERNEL \
@srcdir@/../../src/INTERP_KERNEL/Bases \
OverlapDEC.* \
DEC.* \
DisjointDEC.* \
- MPIProcessorGroup.* \
+ MPIProcessorGroup.* \
StructuredCoincidentDEC.* \
ExplicitCoincidentDEC.* \
NonCoincidentDEC.* \
--- /dev/null
+// This file contains some code used for
+// 1) generation of documentation for inline methods of array classes
+// 2) grouping all methods into 3 lists" "Basic API", "Advanced API" and "Others..."
+
+/* class ParaMEDMEM::DataArray
+ * @defgroup basic_api Basic API
+ * @defgroup adv_api Advanced API
+ */
+
+namespace ParaMEDMEM
+{
+/*!
+ * Returns the attribute \a _name of \a this array.
+ * See \ref MEDCouplingArrayBasicsName "DataArrays infos" for more information.
+ * \return std::string - array name
+ */
+std::string DataArray::getName() const {}
+
+/*!
+ * Returns number of components of \a this array.
+ * See \ref MEDCouplingArrayBasicsTuplesAndCompo "DataArrays infos" for more information.
+ * \return int - number of components
+ */
+int DataArray::getNumberOfComponents() const {}
+
+/*!
+ * Returns number of tuples of \a this array.
+ * See \ref MEDCouplingArrayBasicsName "DataArrays infos" for more information.
+ * \return int - number of tuples
+ */
+int DataArray::getNumberOfTuples() const {}
+
+/*!
+ * Returns number of elements of \a this array.
+ * See \ref MEDCouplingArrayBasicsName "DataArrays infos" for more information.
+ * \return int - number of elements == <em> this->getNumberOfTuples() *
+ * this->getNumberOfComponents() </em>
+ */
+int DataArray::getNbOfElems() const {}
+
+/*!
+ * Throws an exception if number of elements in \a this array differs from a given one.
+ * See \ref MEDCouplingArrayBasicsName "DataArrays infos" for more information.
+ * \param [in] nbOfElems - expected array size.
+ * \param [in] msg - message to return within the thrown exception.
+ * \throw if <em> this->getNbOfElems() != nbOfElems</em>.
+ */
+void DataArray::checkNbOfElems(int nbOfElems, const char *msg) const {}
+
+/*!
+ * Returns values of a specified tuple.
+ * \param [in] tupleId - index of the tuple of interest.
+ * \param [out] res - C array returning values of the \a tupleId-th tuple. The \a res
+ * must be allocated by the caller and be of size not less than \a
+ * this->getNumberOfComponents().
+ */
+void DataArrayDouble::getTuple(int tupleId, double *res) const {}
+
+/*!
+ * Returns a value of a specified element of \a this array.
+ * \param [in] tupleId - index of the tuple of interest.
+ * \param [in] compoId - index of the component of interest.
+ * \return double - the value of \a compoId-th component of \a tupleId-th tuple.
+ */
+double DataArrayDouble::getIJ(int tupleId, int compoId) const {}
+
+/*!
+ * Returns a pointer to the first element of the raw data of \a this array.
+ * \return double* - the pointer to the value of 0-th tuple and 0-th component.
+ */
+double * DataArrayDouble::getPointer() {}
+
+/*!
+ * Returns a const pointer to the first element of the raw data of \a this array.
+ * \return const double* - the pointer to the value of 0-th tuple and 0-th component.
+ */
+const double * DataArrayDouble::getConstPointer() const {}
+
+/*!
+ * Assigns a given value to a specified element of \a this array.
+ * \param [in] tupleId - index of the tuple to modify.
+ * \param [in] compoId - index of the component to modify.
+ * \param [in] newVal - the value to assign to the value at \a compoId-th component
+ * of \a tupleId-th tuple.
+ */
+void DataArrayDouble::setIJ(int tupleId, int compoId, double newVal) {}
+
+/*!
+ * Assigns a given value to a specified element of \a this array which is not marked
+ * as changed.
+ * \param [in] tupleId - index of the tuple to modify.
+ * \param [in] compoId - index of the component to modify.
+ * \param [in] newVal - the value to assign to the value at \a compoId-th component
+ * of \a tupleId-th tuple.
+ */
+void DataArrayDouble::setIJSilent(int tupleId, int compoId, double newVal) {}
+
+/*!
+ * Copies values from another array starting from a specified element of \a this.
+ * \param [in] id - index of element to assign the value \a element0 to.
+ * \param [in] element0 - value to assign to the \a id-th element of \a this.
+ * \param [in] others - values to assign to elements following the \a id-th
+ * element of \a this.
+ * \param [in] sizeOfOthers - number of values to copy from \a others.
+ */
+void DataArrayDouble::writeOnPlace(int id, double element0, const double *others, int sizeOfOthers) {}
+
+/*!
+ * Does nothing because this class does not aggregate any TimeLabel instance.
+ */
+void DataArrayDouble::updateTime() const {}
+
+/*!
+ * Returns values of a specified tuple.
+ * \param [in] tupleId - index of the tuple of interest.
+ * \param [out] res - C array returning values of the \a tupleId-th tuple. The \a res
+ * must be allocated by the caller and be of size not less than \a
+ * this->getNumberOfComponents().
+ *
+ * \ref py_mcdataarrayint_getTuple "Here is a Python example".
+ */
+void DataArrayInt::getTuple(int tupleId, int *res) const {}
+
+/*!
+ * Returns a value of a specified element of \a this array.
+ * \param [in] tupleId - index of the tuple of interest.
+ * \param [in] compoId - index of the component of interest.
+ * \return int - the value of \a compoId-th component of \a tupleId-th tuple.
+ */
+int DataArrayInt::getIJ(int tupleId, int compoId) const {}
+
+
+/*!
+ * Assigns a given value to a specified element of \a this array.
+ * \param [in] tupleId - index of the tuple to modify.
+ * \param [in] compoId - index of the component to modify.
+ * \param [in] newVal - the value to assign to the value at \a compoId-th component
+ * of \a tupleId-th tuple.
+ * \warning As this method declares \a this array as modified, it is more optimal to use
+ * setIJSilent() for modification of muliple values of array and to call
+ * declareAsNew() after the modification is done.
+ */
+void DataArrayInt::setIJ(int tupleId, int compoId, int newVal) {}
+
+
+/*!
+ * Assigns a given value to a specified element of \a this array which is \b not marked
+ * as changed.
+ * \param [in] tupleId - index of the tuple to modify.
+ * \param [in] compoId - index of the component to modify.
+ * \param [in] newVal - the value to assign to the value at \a compoId-th component
+ * of \a tupleId-th tuple.
+ */
+void DataArrayInt::setIJSilent(int tupleId, int compoId, int newVal) {}
+
+/*!
+ * Returns a pointer to the first element of the raw data of \a this array.
+ * \return int* - the pointer to the value of 0-th tuple and 0-th component.
+ */
+int * DataArrayInt::getPointer() {}
+
+/*!
+ * Returns a const pointer to the first element of the raw data of \a this array.
+ * \return const int* - the pointer to the value of 0-th tuple and 0-th component.
+ */
+const int * DataArrayInt::getConstPointer() const {}
+
+/*!
+ * Copies values from another array starting from a given element of \a this.
+ * \param [in] id - index of element to assign the value \a element0 to.
+ * \param [in] element0 - value to assign to the \a id-th element of \a this.
+ * \param [in] others - values to assign to elements following the \a id-th
+ * element of \a this.
+ * \param [in] sizeOfOthers - number of values to copy from \a others.
+ */
+void DataArrayInt::writeOnPlace(int id, int element0, const int *others, int sizeOfOthers) {}
+
+}
+
+namespace ParaMEDMEM
+{
+//================================================================================
+/////////////////////// DataArray GROUPPING //////////////////////////////////////
+//================================================================================
+
+/*! \name Basic API */
+///@{
+DataArray::setName(const char *name);
+DataArray::copyStringInfoFrom(const DataArray& other);
+DataArray::areInfoEquals(const DataArray& other) const;
+DataArray::getName() const;
+DataArray::setInfoOnComponents(const std::vector<std::string>& info);
+DataArray::getVarOnComponent(int i) const;
+DataArray::getUnitOnComponent(int i) const;
+DataArray::setInfoOnComponent(int i, const char *info);
+DataArray::getNumberOfComponents() const;
+DataArray::getNumberOfTuples() const;
+DataArray::getNbOfElems() const;
+DataArray::checkNbOfElems(int nbOfElems, const char *msg) const;
+DataArray::GetVarNameFromInfo(const std::string& info);
+DataArray::GetUnitFromInfo(const std::string& info);
+///@}
+
+/*! \name Others... */
+///@{
+DataArray::getHeapMemorySize() const;
+DataArray::copyPartOfStringInfoFrom(const DataArray& other, const std::vector<int>& compoIds);
+DataArray::copyPartOfStringInfoFrom2(const std::vector<int>& compoIds, const DataArray& other);
+DataArray::areInfoEqualsIfNotWhy(const DataArray& other, std::string& reason) const;
+DataArray::reprWithoutNameStream(std::ostream& stream) const;
+DataArray::cppRepr(const char *varName) const;
+DataArray::getInfoOnComponents() const;
+DataArray::getInfoOnComponents();
+DataArray::getVarsOnComponent() const;
+DataArray::getUnitsOnComponent() const;
+DataArray::getInfoOnComponent(int i) const;
+DataArray::checkNbOfTuples(int nbOfTuples, const char *msg) const;
+DataArray::checkNbOfComps(int nbOfCompo, const char *msg) const;
+DataArray::checkNbOfTuplesAndComp(const DataArray& other, const char *msg) const throw(INTERP_KERNEL::Exception);
+DataArray::checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const char *msg) const throw(INTERP_KERNEL::Exception);
+DataArray::GetNumberOfItemGivenBES(int begin, int end, int step, const char *msg);
+DataArray::GetNumberOfItemGivenBESRelative(int begin, int end, int step, const char *msg);
+DataArray::GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step);
+DataArray::reprCppStream(const char *varName, std::ostream& stream) const;
+DataArray::DataArray();
+DataArray::CheckValueInRange(int ref, int value, const char *msg);
+DataArray::CheckValueInRangeEx(int value, int start, int end, const char *msg);
+DataArray::CheckClosingParInRange(int ref, int value, const char *msg);
+std::string DataArray::_name;
+std::vector<std::string> DataArray::_info_on_compo;
+///@}
+
+//================================================================================
+/////////////////////// DataArrayDouble GROUPPING ////////////////////////////////
+//================================================================================
+
+/*! \name Basic API */
+///@{
+DataArrayDouble::isAllocated() const;
+DataArrayDouble::setInfoAndChangeNbOfCompo(const std::vector<std::string>& info);
+DataArrayDouble::doubleValue() const;
+DataArrayDouble::empty() const;
+DataArrayDouble::deepCpy() const;
+DataArrayDouble::performCpy(bool deepCpy) const;
+DataArrayDouble::cpyFrom(const DataArrayDouble& other);
+DataArrayDouble::alloc(int nbOfTuple, int nbOfCompo);
+DataArrayDouble::allocIfNecessary(int nbOfTuple, int nbOfCompo);
+DataArrayDouble::fillWithZero();
+DataArrayDouble::fillWithValue(double val);
+DataArrayDouble::iota(double init=0.);
+DataArrayDouble::isUniform(double val, double eps) const;
+DataArrayDouble::sort(bool asc=true);
+DataArrayDouble::reverse();
+DataArrayDouble::checkMonotonic(bool increasing, double eps) const;
+DataArrayDouble::isMonotonic(bool increasing, double eps) const;
+DataArrayDouble::repr() const;
+DataArrayDouble::isEqual(const DataArrayDouble& other, double prec) const;
+DataArrayDouble::isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const;
+DataArrayDouble::reAlloc(int nbOfTuples);
+DataArrayDouble::convertToIntArr() const;
+DataArrayDouble::fromNoInterlace() const;
+DataArrayDouble::toNoInterlace() const;
+DataArrayDouble::renumberInPlace(const int* old2New);
+DataArrayDouble::renumberInPlaceR(const int* new2Old);
+DataArrayDouble::renumber(const int* old2New) const;
+DataArrayDouble::renumberR(const int* new2Old) const;
+DataArrayDouble::renumberAndReduce(const int* old2New, int newNbOfTuple) const;
+DataArrayDouble::selectByTupleId(const int* new2OldBg, const int* new2OldEnd) const;
+DataArrayDouble::selectByTupleIdSafe(const int* new2OldBg, const int* new2OldEnd) const;
+DataArrayDouble::selectByTupleId2(int bg, int end2, int step) const;
+DataArrayDouble::selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const;
+DataArrayDouble::substr(int tupleIdBg, int tupleIdEnd=-1) const;
+DataArrayDouble::rearrange(int newNbOfCompo);
+DataArrayDouble::transpose();
+DataArrayDouble::changeNbOfComponents(int newNbOfComp, double dftValue) const;
+DataArrayDouble::keepSelectedComponents(const std::vector<int>& compoIds) const;
+DataArrayDouble::meldWith(const DataArrayDouble* other);
+DataArrayDouble::findCommonTuples(double prec, int limitTupleId, DataArrayInt *&comm, DataArrayInt *&commIndex) const;
+DataArrayDouble::getDifferentValues(double prec, int limitTupleId=-1) const;
+DataArrayDouble::setSelectedComponents(const DataArrayDouble* a, const std::vector<int>& compoIds);
+DataArrayDouble::setPartOfValues1(const DataArrayDouble* a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
+DataArrayDouble::setPartOfValuesSimple1(double a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp);
+DataArrayDouble::setPartOfValues2(const DataArrayDouble* a, const int* bgTuples, const int* endTuples, const int* bgComp, const int* endComp, bool strictCompoCompare=true);
+DataArrayDouble::setPartOfValuesSimple2(double a, const int* bgTuples, const int* endTuples, const int* bgComp, const int* endComp);
+DataArrayDouble::setPartOfValues3(const DataArrayDouble* a, const int* bgTuples, const int* endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
+DataArrayDouble::setPartOfValuesSimple3(double a, const int* bgTuples, const int* endTuples, int bgComp, int endComp, int stepComp);
+DataArrayDouble::getTuple(int tupleId, double* res) const;
+DataArrayDouble::getIJ(int tupleId, int compoId) const;
+DataArrayDouble::back() const;
+DataArrayDouble::getIJSafe(int tupleId, int compoId) const;
+DataArrayDouble::setIJ(int tupleId, int compoId, double newVal);
+DataArrayDouble::setIJSilent(int tupleId, int compoId, double newVal);
+DataArrayDouble::useExternalArrayWithRWAccess(const double* array, int nbOfTuple, int nbOfCompo);
+DataArrayDouble::writeOnPlace(int id, double element0, const double* others, int sizeOfOthers);
+DataArrayDouble::checkNoNullValues() const;
+DataArrayDouble::getMinMaxPerComponent(double* bounds) const;
+DataArrayDouble::getMaxValue(int& tupleId) const;
+DataArrayDouble::getMaxValueInArray() const;
+DataArrayDouble::getMinValue(int& tupleId) const;
+DataArrayDouble::getMinValueInArray() const;
+DataArrayDouble::getMaxValue2(DataArrayInt*& tupleIds) const;
+DataArrayDouble::getMinValue2(DataArrayInt*& tupleIds) const;
+DataArrayDouble::getAverageValue() const;
+DataArrayDouble::norm2() const;
+DataArrayDouble::normMax() const;
+DataArrayDouble::accumulate(double* res) const;
+DataArrayDouble::accumulate(int compId) const;
+DataArrayDouble::fromPolarToCart() const;
+DataArrayDouble::fromCylToCart() const;
+DataArrayDouble::fromSpherToCart() const;
+DataArrayDouble::doublyContractedProduct() const;
+DataArrayDouble::determinant() const;
+DataArrayDouble::eigenValues() const;
+DataArrayDouble::eigenVectors() const;
+DataArrayDouble::inverse() const;
+DataArrayDouble::trace() const;
+DataArrayDouble::deviator() const;
+DataArrayDouble::magnitude() const;
+DataArrayDouble::maxPerTuple() const;
+DataArrayDouble::sortPerTuple(bool asc);
+DataArrayDouble::abs();
+DataArrayDouble::applyLin(double a, double b, int compoId);
+DataArrayDouble::applyLin(double a, double b);
+DataArrayDouble::applyInv(double numerator);
+DataArrayDouble::negate() const;
+DataArrayDouble::applyFunc(int nbOfComp, const char* func) const;
+DataArrayDouble::applyFunc(const char* func) const;
+DataArrayDouble::applyFunc2(int nbOfComp, const char* func) const;
+DataArrayDouble::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char* func) const;
+DataArrayDouble::getIdsInRange(double vmin, double vmax) const;
+DataArrayDouble::addEqual(const DataArrayDouble* other);
+DataArrayDouble::substractEqual(const DataArrayDouble* other);
+DataArrayDouble::multiplyEqual(const DataArrayDouble* other);
+DataArrayDouble::divideEqual(const DataArrayDouble* other);
+DataArrayDouble::updateTime() const;
+DataArrayDouble::New();
+DataArrayDouble::Aggregate(const DataArrayDouble* a1, const DataArrayDouble* a2);
+DataArrayDouble::Aggregate(const std::vector<const DataArrayDouble *>& arr);
+DataArrayDouble::Meld(const DataArrayDouble* a1, const DataArrayDouble* a2);
+DataArrayDouble::Meld(const std::vector<const DataArrayDouble *>& arr);
+DataArrayDouble::Dot(const DataArrayDouble* a1, const DataArrayDouble* a2);
+DataArrayDouble::CrossProduct(const DataArrayDouble* a1, const DataArrayDouble* a2);
+DataArrayDouble::Max(const DataArrayDouble* a1, const DataArrayDouble* a2);
+DataArrayDouble::Min(const DataArrayDouble* a1, const DataArrayDouble* a2);
+DataArrayDouble::Add(const DataArrayDouble* a1, const DataArrayDouble* a2);
+DataArrayDouble::Substract(const DataArrayDouble* a1, const DataArrayDouble* a2);
+DataArrayDouble::Multiply(const DataArrayDouble* a1, const DataArrayDouble* a2);
+DataArrayDouble::Divide(const DataArrayDouble* a1, const DataArrayDouble* a2);
+///@}
+
+/*! \name Advanced API */
+///@{
+DataArrayDouble::checkAllocated() const;
+DataArrayDouble::setPartOfValuesAdv(const DataArrayDouble* a, const DataArrayInt* tuplesSelec);
+DataArrayDouble::setContigPartOfSelectedValues(int tupleIdStart, const DataArrayDouble* a, const DataArrayInt* tuplesSelec);
+DataArrayDouble::setContigPartOfSelectedValues2(int tupleIdStart, const DataArrayDouble* a, int bg, int end2, int step);
+DataArrayDouble::applyFunc(int nbOfComp, FunctionToEvaluate func) const;
+///@}
+
+/*! \name Others... */
+///@{
+DataArrayDouble::getNumberOfTuples() const;
+DataArrayDouble::getNbOfElems() const;
+DataArrayDouble::getHeapMemorySize() const;
+DataArrayDouble::reserve(int nbOfElems);
+DataArrayDouble::pushBackSilent(double val);
+DataArrayDouble::popBackSilent();
+DataArrayDouble::pack() const;
+DataArrayDouble::getNbOfElemAllocated() const;
+DataArrayDouble::reprZip() const;
+DataArrayDouble::writeVTK(std::ostream& ofs, int indent, const char* nameInFile) const;
+DataArrayDouble::reprStream(std::ostream& stream) const;
+DataArrayDouble::reprZipStream(std::ostream& stream) const;
+DataArrayDouble::reprWithoutNameStream(std::ostream& stream) const;
+DataArrayDouble::reprZipWithoutNameStream(std::ostream& stream) const;
+DataArrayDouble::reprCppStream(const char* varName, std::ostream& stream) const;
+DataArrayDouble::isEqualIfNotWhy(const DataArrayDouble& other, double prec, std::string& reason) const;
+DataArrayDouble::duplicateEachTupleNTimes(int nbTimes) const;
+DataArrayDouble::setPartOfValues4(const DataArrayDouble* a, int bgTuples, int endTuples, int stepTuples, const int* bgComp, const int* endComp, bool strictCompoCompare=true);
+DataArrayDouble::setPartOfValuesSimple4(double a, int bgTuples, int endTuples, int stepTuples, const int* bgComp, const int* endComp);
+DataArrayDouble::getPointer();
+DataArrayDouble::SetArrayIn(DataArrayDouble* newArray, DataArrayDouble* &arrayToSet);
+DataArrayDouble::iterator();
+DataArrayDouble::getConstPointer() const;
+DataArrayDouble::begin() const;
+DataArrayDouble::end() const;
+DataArrayDouble::useArray(const double* array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
+DataArrayDouble::insertAtTheEnd(InputIterator first, InputIterator last);
+DataArrayDouble::computeBBoxPerTuple(double epsilon=0.0) const;
+DataArrayDouble::computeTupleIdsNearTuples(const DataArrayDouble* other, double eps, DataArrayInt *& c, DataArrayInt *& cI) const;
+DataArrayDouble::recenterForMaxPrecision(double eps);
+DataArrayDouble::distanceToTuple(const double* tupleBg, const double* tupleEnd, int& tupleId) const;
+DataArrayDouble::buildEuclidianDistanceDenseMatrix() const;
+DataArrayDouble::buildEuclidianDistanceDenseMatrixWith(const DataArrayDouble* other) const;
+DataArrayDouble::applyFuncFast32(const char* func);
+DataArrayDouble::applyFuncFast64(const char* func);
+DataArrayDouble::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
+DataArrayDouble::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
+DataArrayDouble::resizeForUnserialization(const std::vector<int>& tinyInfoI);
+DataArrayDouble::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
+
+DataArrayDouble::findCommonTuplesAlg(const double* bbox, int nbNodes, int limitNodeId, double prec, DataArrayInt* c, DataArrayInt* cI) const;
+
+DataArrayDouble::FindTupleIdsNearTuplesAlg(const BBTree<SPACEDIM,int>& myTree, const double* pos, int nbOfTuples, double eps, DataArrayInt* c, DataArrayInt* cI);
+DataArrayDouble::DataArrayDouble();
+MemArray<double> DataArrayDouble::_mem;
+///@}
+
+//================================================================================
+/////////////////////// DataArrayInt GROUPPING ///////////////////////////////////
+//================================================================================
+
+/*! \name Advanced API */
+///@{
+DataArrayInt::checkAllocated() const;
+DataArrayInt::getHashCode() const;
+DataArrayInt::buildPermutationArr(const DataArrayInt& other) const;
+DataArrayInt::transformWithIndArr(const int* indArrBg, const int* indArrEnd);
+DataArrayInt::transformWithIndArrR(const int* indArrBg, const int* indArrEnd) const;
+DataArrayInt::splitByValueRange(const int* arrBg, const int* arrEnd,DataArrayInt *& castArr, DataArrayInt *& rankInsideCast, DataArrayInt *& castsPresent) const;
+DataArrayInt::setPartOfValuesAdv(const DataArrayInt* a, const DataArrayInt* tuplesSelec);
+DataArrayInt::setContigPartOfSelectedValues(int tupleIdStart, const DataArrayInt*a, const DataArrayInt* tuplesSelec);
+DataArrayInt::setContigPartOfSelectedValues2(int tupleIdStart, const DataArrayInt* a, int bg, int end2, int step);
+DataArrayInt::SetArrayIn(DataArrayInt* newArray, DataArrayInt* &arrayToSet);
+///@}
+
+/*! \name Basic API */
+///@{
+DataArrayInt::isAllocated() const;
+DataArrayInt::setInfoAndChangeNbOfCompo(const std::vector<std::string>& info);
+DataArrayInt::intValue() const;
+DataArrayInt::empty() const;
+DataArrayInt::deepCpy() const;
+DataArrayInt::performCpy(bool deepCpy) const;
+DataArrayInt::cpyFrom(const DataArrayInt& other);
+DataArrayInt::alloc(int nbOfTuple, int nbOfCompo);
+DataArrayInt::allocIfNecessary(int nbOfTuple, int nbOfCompo);
+DataArrayInt::isEqual(const DataArrayInt& other) const;
+DataArrayInt::isEqualWithoutConsideringStr(const DataArrayInt& other) const;
+DataArrayInt::isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const;
+DataArrayInt::sort(bool asc=true);
+DataArrayInt::reverse();
+DataArrayInt::fillWithZero();
+DataArrayInt::fillWithValue(int val);
+DataArrayInt::iota(int init=0);
+DataArrayInt::repr() const;
+DataArrayInt::invertArrayO2N2N2O(int newNbOfElem) const;
+DataArrayInt::invertArrayN2O2O2N(int oldNbOfElem) const;
+DataArrayInt::reAlloc(int nbOfTuples);
+DataArrayInt::convertToDblArr() const;
+DataArrayInt::fromNoInterlace() const;
+DataArrayInt::toNoInterlace() const;
+DataArrayInt::renumberInPlace(const int* old2New);
+DataArrayInt::renumberInPlaceR(const int* new2Old);
+DataArrayInt::renumber(const int* old2New) const;
+DataArrayInt::renumberR(const int* new2Old) const;
+DataArrayInt::renumberAndReduce(const int* old2NewBg, int newNbOfTuple) const;
+DataArrayInt::selectByTupleId(const int* new2OldBg, const int* new2OldEnd) const;
+DataArrayInt::selectByTupleIdSafe(const int* new2OldBg, const int* new2OldEnd) const;
+DataArrayInt::selectByTupleId2(int bg, int end, int step) const;
+DataArrayInt::selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const;
+DataArrayInt::checkAndPreparePermutation() const;
+DataArrayInt::changeSurjectiveFormat(int targetNb, DataArrayInt *&arr, DataArrayInt *&arrI) const;
+DataArrayInt::buildPermArrPerLevel() const;
+DataArrayInt::isIdentity() const;
+DataArrayInt::isUniform(int val) const;
+DataArrayInt::substr(int tupleIdBg, int tupleIdEnd=-1) const;
+DataArrayInt::rearrange(int newNbOfCompo);
+DataArrayInt::transpose();
+DataArrayInt::changeNbOfComponents(int newNbOfComp, int dftValue) const;
+DataArrayInt::keepSelectedComponents(const std::vector<int>& compoIds) const;
+DataArrayInt::meldWith(const DataArrayInt* other);
+DataArrayInt::setSelectedComponents(const DataArrayInt* a, const std::vector<int>& compoIds);
+DataArrayInt::setPartOfValues1(const DataArrayInt* a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
+DataArrayInt::setPartOfValuesSimple1(int a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp);
+DataArrayInt::setPartOfValues2(const DataArrayInt* a, const int* bgTuples, const int* endTuples, const int* bgComp, const int* endComp, bool strictCompoCompare=true);
+DataArrayInt::setPartOfValuesSimple2(int a, const int* bgTuples, const int* endTuples, const int* bgComp, const int* endComp);
+DataArrayInt::setPartOfValues3(const DataArrayInt* a, const int* bgTuples, const int* endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
+DataArrayInt::setPartOfValuesSimple3(int a, const int* bgTuples, const int* endTuples, int bgComp, int endComp, int stepComp);
+DataArrayInt::getTuple(int tupleId, int* res) const;
+DataArrayInt::getIJ(int tupleId, int compoId) const;
+DataArrayInt::getIJSafe(int tupleId, int compoId) const;
+DataArrayInt::back() const;
+DataArrayInt::setIJ(int tupleId, int compoId, int newVal);
+DataArrayInt::setIJSilent(int tupleId, int compoId, int newVal);
+DataArrayInt::getPointer();
+DataArrayInt::getConstPointer() const;
+DataArrayInt::getIdsEqual(int val) const;
+DataArrayInt::getIdsNotEqual(int val) const;
+DataArrayInt::getIdsEqualList(const int* valsBg, const int* valsEnd) const;
+DataArrayInt::getIdsNotEqualList(const int* valsBg, const int* valsEnd) const;
+DataArrayInt::changeValue(int oldValue, int newValue);
+DataArrayInt::presenceOfValue(int value) const;
+DataArrayInt::presenceOfValue(const std::vector<int>& vals) const;
+DataArrayInt::getMaxValue(int& tupleId) const;
+DataArrayInt::getMaxValueInArray() const;
+DataArrayInt::getMinValue(int& tupleId) const;
+DataArrayInt::getMinValueInArray() const;
+DataArrayInt::abs();
+DataArrayInt::applyLin(int a, int b, int compoId);
+DataArrayInt::applyLin(int a, int b);
+DataArrayInt::applyInv(int numerator);
+DataArrayInt::negate() const;
+DataArrayInt::applyDivideBy(int val);
+DataArrayInt::applyModulus(int val);
+DataArrayInt::applyRModulus(int val);
+DataArrayInt::buildComplement(int nbOfElement) const;
+DataArrayInt::buildSubstraction(const DataArrayInt* other) const;
+DataArrayInt::buildUnion(const DataArrayInt* other) const;
+DataArrayInt::buildIntersection(const DataArrayInt* other) const;
+DataArrayInt::deltaShiftIndex() const;
+DataArrayInt::computeOffsets();
+DataArrayInt::computeOffsets2();
+DataArrayInt::buildExplicitArrByRanges(const DataArrayInt* offsets) const;
+DataArrayInt::useArray(const int* array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
+DataArrayInt::writeOnPlace(int id, int element0, const int* others, int sizeOfOthers);
+DataArrayInt::addEqual(const DataArrayInt* other);
+DataArrayInt::substractEqual(const DataArrayInt* other);
+DataArrayInt::multiplyEqual(const DataArrayInt* other);
+DataArrayInt::divideEqual(const DataArrayInt* other);
+DataArrayInt::modulusEqual(const DataArrayInt* other);
+DataArrayInt::updateTime() const;
+DataArrayInt::New();
+DataArrayInt::BuildOld2NewArrayFromSurjectiveFormat2(int nbOfOldTuples, const int* arr, const int* arrIBg, const int* arrIEnd, int &newNbOfTuples);
+DataArrayInt::Aggregate(const DataArrayInt* a1, const DataArrayInt* a2, int offsetA2);
+DataArrayInt::Aggregate(const std::vector<const DataArrayInt *>& arr);
+DataArrayInt::Meld(const DataArrayInt* a1, const DataArrayInt* a2);
+DataArrayInt::Meld(const std::vector<const DataArrayInt *>& arr);
+DataArrayInt::MakePartition(const std::vector<const DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups);
+DataArrayInt::BuildUnion(const std::vector<const DataArrayInt *>& arr);
+DataArrayInt::BuildIntersection(const std::vector<const DataArrayInt *>& arr);
+DataArrayInt::Add(const DataArrayInt* a1, const DataArrayInt* a2);
+DataArrayInt::Substract(const DataArrayInt* a1, const DataArrayInt* a2);
+DataArrayInt::Multiply(const DataArrayInt* a1, const DataArrayInt* a2);
+DataArrayInt::Divide(const DataArrayInt* a1, const DataArrayInt* a2);
+DataArrayInt::Modulus(const DataArrayInt* a1, const DataArrayInt* a2);
+DataArrayInt::CheckAndPreparePermutation(const int* start, const int* end);
+DataArrayInt::Range(int begin, int end, int step);
+///@}
+
+/*! \name Others... */
+///@{
+DataArrayInt::getNumberOfTuples() const;
+DataArrayInt::getNbOfElems() const;
+DataArrayInt::getHeapMemorySize() const;
+DataArrayInt::reserve(int nbOfElems);
+DataArrayInt::pushBackSilent(int val);
+DataArrayInt::popBackSilent();
+DataArrayInt::pack() const;
+DataArrayInt::getNbOfElemAllocated() const;
+DataArrayInt::isEqualIfNotWhy(const DataArrayInt& other, std::string& reason) const;
+DataArrayInt::checkMonotonic(bool increasing) const;
+DataArrayInt::isMonotonic(bool increasing) const;
+DataArrayInt::checkStrictlyMonotonic(bool increasing) const;
+DataArrayInt::isStrictlyMonotonic(bool increasing) const;
+DataArrayInt::reprZip() const;
+DataArrayInt::writeVTK(std::ostream& ofs, int indent, const char* type, const char* nameInFile) const;
+DataArrayInt::reprStream(std::ostream& stream) const;
+DataArrayInt::reprZipStream(std::ostream& stream) const;
+DataArrayInt::reprWithoutNameStream(std::ostream& stream) const;
+DataArrayInt::reprZipWithoutNameStream(std::ostream& stream) const;
+DataArrayInt::reprCppStream(const char* varName, std::ostream& stream) const;
+DataArrayInt::invertArrayO2N2N2OBis(int newNbOfElem) const;
+DataArrayInt::setPartOfValues4(const DataArrayInt* a, int bgTuples, int endTuples, int stepTuples, const int* bgComp, const int* endComp, bool strictCompoCompare=true);
+DataArrayInt::setPartOfValuesSimple4(int a, int bgTuples, int endTuples, int stepTuples, const int* bgComp, const int* endComp);
+DataArrayInt::iterator();
+DataArrayInt::begin() const;
+DataArrayInt::end() const;
+DataArrayInt::locateTuple(const std::vector<int>& tupl) const;
+DataArrayInt::locateValue(int value) const;
+DataArrayInt::locateValue(const std::vector<int>& vals) const;
+DataArrayInt::search(const std::vector<int>& vals) const;
+DataArrayInt::presenceOfTuple(const std::vector<int>& tupl) const;
+DataArrayInt::accumulate(int* res) const;
+DataArrayInt::accumulate(int compId) const;
+DataArrayInt::getIdsInRange(int vmin, int vmax) const;
+DataArrayInt::buildSubstractionOptimized(const DataArrayInt* other) const;
+DataArrayInt::buildUnique() const;
+DataArrayInt::findRangeIdForEachTuple(const DataArrayInt* ranges) const;
+DataArrayInt::findIdInRangeForEachTuple(const DataArrayInt* ranges) const;
+DataArrayInt::duplicateEachTupleNTimes(int nbTimes) const;
+DataArrayInt::getDifferentValues() const;
+> DataArrayInt::partitionByDifferentValues(std::vector<int>& differentIds) const;
+DataArrayInt::useExternalArrayWithRWAccess(const int* array, int nbOfTuple, int nbOfCompo);
+tor>
+DataArrayInt::insertAtTheEnd(InputIterator first, InputIterator last);
+DataArrayInt::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
+DataArrayInt::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
+DataArrayInt::resizeForUnserialization(const std::vector<int>& tinyInfoI);
+DataArrayInt::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
+DataArrayInt::DataArrayInt();
+MemArray<int> DataArrayInt::_mem;
+///@}
+
+}
\f]
\f$W\f$ is called the \anchor interpolationmatrix interpolation matrix.
-The objectives of interpolators is to compute the matrix W depending on their physical
-properties (\ref IntExtFields) and their mesh discretisation (P0, P1,...).
+The objective of interpolators is to compute the matrix W depending on their physical
+properties (\ref IntExtFields) and their mesh discretisation (on cells P0, on nodes P1,...).
\section ConsInterp Conservative interpolation
\sum_{S_j} Vol(T_i\cap S_j) = Vol(T_i),\hspace{1cm} and \hspace{1cm} \sum_{T_i} Vol(S_j\cap T_i) = Vol(S_j)
\f]
then the meshes S and T are said to be \b
-overlapping and all the algorithms will return the same results.
+overlapping. In this case the two formulas in a given column in the table below give the same
+result. All intensive formulas result in the same output, and all the extensive formulas give also the same output.
-The ideal interpolation algorithm should be conservative and respect the maximum principle. However such an algorithm can be impossible to design if the two meshes do not overlap. When the meshes do not overlap, using either \f$Vol(T_i)\f$ or \f$\sum_{S_j} Vol(T_i\cap S_j)\f$ in the formula one obtains an algorithm that respects either conservativity either the maximum principle (see the nature of field \ref TableNatureOfField "summary table").
+The ideal interpolation algorithm should be conservative and respect the maximum principle. However such an algorithm can be impossible to design if the two meshes do not overlap. When the meshes do not overlap, using either \f$Vol(T_i)\f$ or \f$\sum_{S_j} Vol(T_i\cap S_j)\f$ one obtains an algorithm that respects either the conservativity or the maximum principle (see the nature of field \ref TableNatureOfField "summary table").
\section InterpKerRemapInt Linear conservative remapping of P0 (cell based) fields
\f]
\section TableNatureOfField Summary
-In the case of fields with P0 representation, if the meshes do not overlap the scheme is either conservative or maximum preserving (not both) and depending on the prioritised property and the \ref NatureOfField the interpolation coefficients take the following value
+In the case of fields with a P0 representation (cell based) and when the meshes do not overlap, the scheme is either conservative or maximum preserving (not both). Depending on the \ref NatureOfField the interpolation coefficients take the following value:
* <TABLE BORDER=1 >
* <TR><TD> </TD><TD>Intensive</TD><TD> extensive </TD></TR>
A \ref ParaMEDMEM::DataArray "DataArray" instance has an attribute **name**.
**name** is particulary useful for \ref ParaMEDMEM::DataArray "DataArray" representing profiles, families, groups, fields in MEDLoader.
-But excepted these useful usecases, **name** attribute is often ignored when \ref ParaMEDMEM::DataArray "DataArrays" are aggregated (field array, connectivity, coordinates) is a bigger object.
-Whatever the useage of the **name** attribute of \ref ParaMEDMEM::DataArray "DataArrays", all methods in ParaMEDMEM::DataArrayDouble and ParaMEDMEM::DataArrayInt class deal with **name** as they do for components names.
+But excepted these useful usecases, **name** attribute is often ignored when \ref ParaMEDMEM::DataArray "DataArrays" are aggregated (field array, connectivity, coordinates) in a bigger object.
+Whatever the usage of the **name** attribute of \ref ParaMEDMEM::DataArray "DataArrays", all methods in ParaMEDMEM::DataArrayDouble and ParaMEDMEM::DataArrayInt class deal with **name** as they do for components names.
\subsection MEDCouplingArrayBasicsTuplesAndCompo Raw data, tuples and components of DataArrays.
The main goal of \ref ParaMEDMEM::DataArray "DataArray" is to store contiguous vector of atomical elements with same basic datatype (signed integers, double precision...). This vector of atomical elements is called **raw data** of \ref ParaMEDMEM::DataArray "DataArray".
-The size of this vector of data is called, number of elements. So the number of bytes stored by a \ref ParaMEDMEM::DataArray "DataArray" instance, is equal to
+The size of this vector of data is called <em>"number of elements"</em>. So the number of bytes stored by a \ref ParaMEDMEM::DataArray "DataArray" instance, is equal to
the product of the __number of elements__ * __constant size of DataType__ .
-As \ref ParaMEDMEM::DataArray "DataArray" instances are designed to stored vector fields, tensor fields, coordinate of nodes, the notion of components has been
-added.
+As \ref ParaMEDMEM::DataArray "DataArray" instances are designed to store vector fields, tensor fields, coordinate of nodes, the notion of _components_ has been added.
So, \ref ParaMEDMEM::DataArray "DataArrays" have an additional attribute that is number of components that represent the size of a contiguous set of atomical elements.
-The vector of atomical elements stored into \ref ParaMEDMEM::DataArray "DataArrays" are grouped in contiguous in memory set of atomical elements having each same size.
+The vector of atomical elements stored into \ref ParaMEDMEM::DataArray "DataArrays" are grouped in contiguous memory set of atomical elements having each same size.
-The contiguous set of atomical elements is called **tuple**. And each **tuple** stored in raw data, have each a length exactly equal to the number of components of
+The contiguous set of atomical elements is called **tuple**. And each **tuple** stored in raw data, have each a length exactly equal to the number of components of
\ref ParaMEDMEM::DataArray "DataArray" storing it.
Thus :
N_{bytes}=N_{elements}*sizeof(DataType)=N_{tuples}*N_{components}*sizeof(DataType).
\f]
-In another words, **raw data** of \ref ParaMEDMEM::DataArray "DataArrays" can be seen as a dense matrix, whose number of components would be the row size and number of tuples
-would be the column size. In this point of view of \ref ParaMEDMEM::DataArray "DataArrays" a **tuple** is represented by the corresponding row in the dense matrix.
+In other words, **raw data** of \ref ParaMEDMEM::DataArray "DataArrays" can be seen as a dense matrix, whose number of components would be the row size and number of tuples
+would be the column size. In this point of view of \ref ParaMEDMEM::DataArray "DataArrays" a **tuple** is represented by the corresponding row in the dense matrix.
Typically in the **raw data** of \ref ParaMEDMEM::DataArray "DataArrays" **number of tuples** is highly bigger than **number of components** !
\section MEDCouplingArraySteps1 Building an array from scratch in C++
-Here a description of typical usages to use \ref ParaMEDMEM::DataArrayDouble "MEDCoupling arrays".\n
+Here is a description of typical usages of \ref ParaMEDMEM::DataArrayDouble "MEDCoupling arrays".
+
In this example we will create arrays with 12 tuples constituted each
of 3 components. These arrays will be created using different ways.\n
- ParaMEDMEM::DataArrayInt::isEqualWithoutConsideringStr
- ParaMEDMEM::DataArrayDouble::isEqualWithoutConsideringStr
+\section MEDCouplingArrayFill Filling DataArray with values
+
+Both DataArrayDouble and DataArrayInt provide comfort methods that
+fill the array with some values. These methods are:
+- ParaMEDMEM::DataArrayInt::fillWithZero and
+ ParaMEDMEM::DataArrayDouble::fillWithZero which assigns zero to all
+ values in array.
+- ParaMEDMEM::DataArrayInt::fillWithValue and
+ ParaMEDMEM::DataArrayDouble::fillWithValue which assigns a certain value to all
+ values in array.
+- ParaMEDMEM::DataArrayInt::iota() and
+ ParaMEDMEM::DataArrayDouble::iota() which assigns incrementing values to all
+ values in array.
+
\section MEDCouplingArrayRenumbering Array renumbering
Here is presented all it is necessary to know concerning renumbering.
Method in new to old mode that works on surjective applications :
- \ref ParaMEDMEM::DataArrayDouble::selectByTupleId "DataArrayDouble::selectByTupleId"
+- \ref ParaMEDMEM::DataArrayDouble::selectByTupleIdSafe "DataArrayDouble::selectByTupleIdSafe"
+- \ref ParaMEDMEM::DataArrayDouble::selectByTupleId2 "DataArrayDouble::selectByTupleId2"
+- \ref ParaMEDMEM::DataArrayDouble::selectByTupleRanges "DataArrayDouble::selectByTupleRanges"
\section MEDCouplingArrayApplyFunc Application of a function on DataArrayDouble instances.
\section IntExtFields Overview: intensive and extensive field
-\c NatureOfField is an enum which helps determining some physical significance of the field and affects the choice of interpolation formula ( see \ref TableNatureOfField).
+\c NatureOfField is an enum which helps determining some physical significance of the field and affects the choice of the interpolation formula (see \ref TableNatureOfField).
It has five possible values:
-- "NoNature", the default value, does not allow the use of interpolation tools
+- "NoNature", the default value, does not allow the use of any interpolation tools
- \ref TableNatureOfFieldExampleConservVol "ConservativeVolumic", for intensive field with the maximum principle favored over conservativity. Relevant for temperature, pression fields.
+- \ref TableNatureOfFieldExampleRevIntegral "RevIntegral", for intensive field with the conservativity favored over maximum principle. Relevant for power density fields.
+
- \ref TableNatureOfFieldExampleIntegral "Integral", for extensive field with the maximum principle favored over conservativity. Relevant for power fields.
- \ref TableNatureOfFieldExampleIntegralGlobConstraint "IntegralGlobConstraint", for extensive fields with conservativity favored over the maximum principle. Relevant for power fields.
-- \ref TableNatureOfFieldExampleRevIntegral "RevIntegral", for intensive field with the conservativity favored over maximum principle. Relevant for power density fields.
+The first two correspond to intensive fields, the last two correspond to extensive fields.
-By an intensive field we mean a field that represent volumetric or intensive physical variable such as density (\f$kg.m^{-3}\f$), power density (\f$W.m^{-3}\f$), temperature (\f$K\f$) or pressure (\f$Pa\f$).
-By extensive (or integral) field we mean a field that represents an extensive physical quantity sych as mass (\f$kg\f$), volume (\f$m^3\f$), a momentum (\f$kg.m.s^{-1}\f$) or power \f$(W\f$).
-For fields with a P0 representation, conservativity formulas are different depending on whether the field is extensive or intensive (see \ref InterpKerP0P0Int and \ref InterpKerP0P0Ext).
-In some cases such a non \ref MeshOverlap "overlapping meshes", it is impossible to fulfill both conservation and maximum principle during the interpolation. The nature of the fields determines the formula to be used for non overlapped cells and thus the property that we will be satisfied.
-We consider that fields with P1 or P2 representations are necessarily intensive.
+By an intensive field we mean a field that represent an intensive physical variable such as density (\f$kg.m^{-3}\f$), power density (\f$W.m^{-3}\f$), temperature (\f$K\f$) or pressure (\f$Pa\f$). Typically the physical value doesn't scale with the size of the underlying geometry.
+By extensive (or integral) field we mean a field that represents an extensive physical quantity such as mass (\f$kg\f$), volume (\f$m^3\f$), a momentum (\f$kg.m.s^{-1}\f$) or power \f$(W\f$).
+Typically the field value scales linearly with respect to the underlying geometry size.
+For fields with a P0 representation (cell based), conservativity formulas are different depending on whether the field is extensive or intensive (see \ref InterpKerP0P0Int and \ref InterpKerP0P0Ext).
+Those two notions are themselves split into two sub-categories.
+Indeed in some cases (e.g. non \ref MeshOverlap "overlapping meshes"), it is impossible to fulfill both the conservation principle and the maximum principle during the interpolation. The nature of the fields determine the formula to be used for non overlapping cells and thus the property that we will be satisfied.
+Finally we consider that fields with P1 or P2 representations are necessarily intensive.
\section Usage
-In order to employ the various \ref interptools, it is important to specify the nature of your field.
-In case the sources and target meshes do not overlap different treatments will be employed, depending on the nature of the source and target fields.
+In order to employ the various \ref interptools, you have to specify the nature of your field.
+When the source and target meshes do not overlap, different treatments will be employed depending on the nature of the source and target fields.
You can specify the nature of the field when you create a \ref medcoupling field with the following constructor:
\code
MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type);
You can notice that it is possible to mix cell types as long as the dimension of cell is exactly equal to meshDim to respect \ref MEDCouplingMeshes "this rule".
-\subpage medcouplingcppexamplesUmeshStdBuild1 "Here the C++ implementation."
+\subpage medcouplingcppexamplesUmeshStdBuild1 "Here is the C++ implementation."
-\subpage medcouplingpyexamplesUmeshStdBuild1 "Here the Python implementation."
+\subpage medcouplingpyexamplesUmeshStdBuild1 "Here is the Python implementation."
\section MEDCouplingUMeshNodalConnectivity How MEDCouplingUMesh stores its nodal connectivity.
The virtual call to ParaMEDMEM::TimeLabel::updateTime change the behaviour of ParaMEDMEM::TimeLabel::getTimeOfThis it is a bug, so please notify the bug into the salome forum.
-*/
\ No newline at end of file
+*/
/*!
\page medcouplingcppexamples <br><h1> MEDCoupling C++ examples </h1>
+
+\anchor cpp_mcdataarrayint_
+<br><h2> </h2>
+
+\snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_
+\snippet MEDCouplingExamplesTest.py PySnippet_DataArrayInt_
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_
+
+
+\anchor cpp_mcdataarrayint_getTuple
+<br><h2> Getting a tuple of DataArrayInt </h2>
+
+In this simple example we create an array of integers arranged into 3
+tuples per 2 components, and finally print the second tuple.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_getTuple_1
+The output is
+<pre> [9, 10] </pre>
+Note that we can traverse all tuples in the array by simply iterating
+over it as the code below does.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_getTuple_2
+Its output follows.
+<pre>
+(7, 8)
+(9, 10)
+(11, 12)
+</pre>
+
+\anchor cpp_mcdataarrayint_buildpermutationarr
+<br><h2> Building a permutation array </h2>
+
+Here we create two arrays containing same values but in different order and then we use
+\ref ParaMEDMEM::DataArrayInt::buildPermutationArr "DataArrayInt::buildPermutationArr()" to get
+an array showing in what places the values of \b b array are located in \b a array.
+\snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_buildPermutationArr_1
+The result array \b c contains [1,0,4,2,3].
+
+<br><h2> Inverting renumbering maps </h2>
+\anchor cpp_mcdataarrayint_invertarrayo2n2n2o
+<h3> invertArrayO2N2N2O() </h3>
+
+In this example we create a DataArrayInt containing a renumbering map in
+"Old to New" mode, convert it into the renumbering map in "New to Old" mode and check the
+result.
+\snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_invertArrayO2N2N2O_1
+
+\anchor cpp_mcdataarrayint_invertarrayn2o2o2n
+<br><h3> invertArrayN2O2O2N() </h3>
+
+In this example we create a DataArrayInt containing a renumbering map in
+"New to Old" mode, convert it into the renumbering map in "Old to New" mode and check the
+result.
+\snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_invertArrayN2O2O2N_1
+
+
+
+\anchor cpp_mcdataarraydouble_getidsinrange
+<br><h2> Finding values in range in DataArrayDouble</h2>
+
+In this example we create an array \b da containing same values as ones returned by
+\c range( \c 10 ). Then we get an array of indices of values of \b da being in
+range [ 2.5, 6 ].
+\snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_getIdsInRange_1
+As result contents of the array \b da2 are as follows.
+<pre>
+ Tuple #0 : 3
+ Tuple #1 : 4
+ Tuple #2 : 5
+ Tuple #3 : 6
+</pre>
+
+
+\anchor cpp_mcdataarraydouble_setselectedcomponents
+<br><h2> Set part of values of DataArrayDouble </h2>
+<h3> setSelectedComponents() </h3>
+First, we create a 'source' array.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setSelectedComponents1
+Now we create a larger zero array and assign the array \b da into it.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setSelectedComponents2
+As result contents of the array \b dv are as follows.
+<pre>
+Info of components : "a2" "a1" "v3" "v4"
+ Tuple #0 : 2 1 0 0
+ Tuple #1 : 4 3 0 0
+ Tuple #2 : 6 5 0 0
+ Tuple #3 : 0 0 0 0
+</pre>
+The same result can be achieved other way (except that component info
+is not copied):
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setSelectedComponents3
+
+\anchor cpp_mcdataarraydouble_setpartofvalues1
+<br><h3> setPartOfValues1() </h3>
+We create two arrays:
+- a "large" (4x4) zero array \b da to assign to and
+- a smaller (2x2) array \b dv filled with values [7.,8.,9.,10].
+
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_1
+Now we copy \b dv to the middle of \b da.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_2
+As result contents of the array \b da are as follows.
+<pre>
+ Info of components :"v1" "v2" "v3" "v4"
+ Tuple #0 : 0 0 0 0
+ Tuple #1 : 0 7 8 0
+ Tuple #2 : 0 9 10 0
+ Tuple #3 : 0 0 0 0
+</pre>
+
+Here we re-fill \b da with zeros and copy \b dv into a component of \b da.
+
+Note that the last parameter \a strictCompoCompare should be \a False
+in this case, else \ref ParaMEDMEM::DataArrayDouble::setPartOfValues1()
+throws an exception because \b da has 2 components but only one target
+component is specified.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_3
+<pre>
+ Tuple #0 : 0 7 0 0
+ Tuple #1 : 0 8 0 0
+ Tuple #2 : 0 9 0 0
+ Tuple #3 : 0 10 0 0
+</pre>
+Below more two variants of location of target values are shown.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_4
+<pre>
+ Tuple #0 : 0 0 0 0
+ Tuple #1 : 7 8 9 10
+ Tuple #2 : 0 0 0 0
+ Tuple #3 : 0 0 0 0
+</pre>
+
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_5
+<pre>
+ Tuple #0 : 0 7 0 8
+ Tuple #1 : 0 0 0 0
+ Tuple #2 : 0 9 0 10
+ Tuple #3 : 0 0 0 0
+</pre>
+The same result can be achieved other way:
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_6
+
+
+
+\anchor cpp_mcdataarraydouble_setpartofvaluessimple1
+<br><h3> setPartOfValuesSimple1() </h3>
+We create an array (4x4) \b da to assign to and define a value \b dv to assign.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_1
+Now we assign \b dv to the middle of \b da.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_2
+As result contents of the array \b da are as follows.
+<pre>
+ Tuple #0 : 0 0 0 0
+ Tuple #1 : 0 7 7 0
+ Tuple #2 : 0 7 7 0
+ Tuple #3 : 0 0 0 0
+</pre>
+
+Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_3
+<pre>
+ Tuple #0 : 0 7 0 0
+ Tuple #1 : 0 7 0 0
+ Tuple #2 : 0 7 0 0
+ Tuple #3 : 0 7 0 0
+</pre>
+Below more two variants of location of target values are shown.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_4
+<pre>
+ Tuple #0 : 0 0 0 0
+ Tuple #1 : 7 7 7 7
+ Tuple #2 : 0 0 0 0
+ Tuple #3 : 0 0 0 0
+</pre>
+
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_5
+<pre>
+ Tuple #0 : 0 7 0 7
+ Tuple #1 : 0 0 0 0
+ Tuple #2 : 0 7 0 7
+ Tuple #3 : 0 0 0 0
+</pre>
+The same result can be achieved other way:
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_6
+
+
+\anchor cpp_mcdataarraydouble_setpartofvaluessimple2
+<br><h3> setPartOfValuesSimple2() </h3>
+We create an array (4x4) \b da to assign to and define a value \b dv to assign.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_1
+Now we assign \b dv to the middle of \b da.
+We explicitly specify tuples and component to assign to by a list [1,2].
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_2
+As result contents of the array \b da are as follows.
+<pre>
+ Tuple #0 : 0 0 0 0
+ Tuple #1 : 0 7 7 0
+ Tuple #2 : 0 7 7 0
+ Tuple #3 : 0 0 0 0
+</pre>
+
+Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_3
+<pre>
+ Tuple #0 : 0 7 0 0
+ Tuple #1 : 0 7 0 0
+ Tuple #2 : 0 7 0 0
+ Tuple #3 : 0 7 0 0
+</pre>
+Below more two variants of location of target values are shown.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_4
+<pre>
+ Tuple #0 : 0 0 0 0
+ Tuple #1 : 7 7 7 7
+ Tuple #2 : 0 0 0 0
+ Tuple #3 : 0 0 0 0
+</pre>
+
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_5
+<pre>
+ Tuple #0 : 0 7 0 7
+ Tuple #1 : 0 0 0 0
+ Tuple #2 : 0 7 0 7
+ Tuple #3 : 0 0 0 0
+</pre>
+\note \ref ParaMEDMEM::DataArrayDouble::setPartOfValuesSimple2() can't
+be explicitly called in Python.
+
+
+\anchor cpp_mcdataarraydouble_setpartofvaluessimple3
+<br><h3> setPartOfValuesSimple3() </h3>
+We create an array (4x4) \b da to assign to and define a value \b dv to assign.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_1
+Now we assign \b dv to the middle of \b da.
+We explicitly specify tuples to assign to by a list [1,2]. And we specify
+components to assign to using slicing: 1:3.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_2
+As result contents of the array \b da are as follows.
+<pre>
+ Tuple #0 : 0 0 0 0
+ Tuple #1 : 0 7 7 0
+ Tuple #2 : 0 7 7 0
+ Tuple #3 : 0 0 0 0
+</pre>
+
+Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_3
+<pre>
+ Tuple #0 : 0 7 0 0
+ Tuple #1 : 0 7 0 0
+ Tuple #2 : 0 7 0 0
+ Tuple #3 : 0 7 0 0
+</pre>
+Below more two variants of location of target values are shown.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_4
+<pre>
+ Tuple #0 : 0 0 0 0
+ Tuple #1 : 7 7 7 7
+ Tuple #2 : 0 0 0 0
+ Tuple #3 : 0 0 0 0
+</pre>
+
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_5
+<pre>
+ Tuple #0 : 0 7 0 7
+ Tuple #1 : 0 0 0 0
+ Tuple #2 : 0 7 0 7
+ Tuple #3 : 0 0 0 0
+</pre>
+\note \ref ParaMEDMEM::DataArrayDouble::setPartOfValuesSimple3() can't
+be explicitly called in Python.
+
+
+\anchor cpp_mcdataarraydouble_setpartofvalues2
+<br><h3> setPartOfValues2() </h3>
+We create two arrays:
+- a "large" (4x7) zero array \b da to assign to,
+- a smaller (3x2) array \b dv filled with values [7.,8.,9.,10.,11.,12.].
+
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues2_1
+Now we assign the two components of \b dv to the components of \b da
+with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
+ indices [0,1,2]. This is the first mode of usage.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues2_2
+As result contents of the array \b da are as follows.
+<pre>
+ Tuple #0 : 0 7 0 8 0 0 0
+ Tuple #1 : 0 9 0 10 0 0 0
+ Tuple #2 : 0 11 0 12 0 0 0
+ Tuple #3 : 0 0 0 0 0 0 0
+</pre>
+Every value of \b dv has been assigned to its own location within \b da.
+
+Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
+And we assign \b dv to the tuples of \b da with indices [0,2,3] .
+This is the second mode of usage.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues2_3
+The contents of \b dv have been assigned to each of specified tuples of \b da.
+Every value of \b dv is repeated in the 3 specified tuples within \b da.
+<pre>
+ Tuple #0 : 7 0 8 9 10 11 12
+ Tuple #1 : 0 0 0 0 0 0 0
+ Tuple #2 : 7 0 8 9 10 11 12
+ Tuple #3 : 7 0 8 9 10 11 12
+</pre>
+\note \ref ParaMEDMEM::DataArrayDouble::setPartOfValues2() can't
+be explicitly called in Python.
+
+
+\anchor cpp_mcdataarraydouble_setpartofvalues3
+<br><h3> setPartOfValues3() </h3>
+We create two arrays:
+- a "large" (4x7) zero array \b da to assign to,
+- a smaller (3x2) array \b dv filled with values [7.,8.,9.,10.,11.,12.].
+
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues3_1
+Now we assign the two components of \b dv to the components of \b da
+with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
+indices [0,1,2] which are specified using slicing: "0:3".
+This is the first mode of usage.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues3_2
+As result contents of the array \b da are as follows.
+<pre>
+ Tuple #0 : 0 7 0 8 0 0 0
+ Tuple #1 : 0 9 0 10 0 0 0
+ Tuple #2 : 0 11 0 12 0 0 0
+ Tuple #3 : 0 0 0 0 0 0 0
+</pre>
+Every value of \b dv has been assigned to its own location within \b da.
+
+Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
+And we assign \b dv to the tuples of \b da with indices [0,2] using \a
+slice notation "0:4:2". This is the second mode of usage.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues3_3
+The contents of \b dv have been assigned to each of specified tuples of \b da.
+Every value of \b dv is repeated in the 3 specified tuples within \b da.
+<pre>
+ Tuple #0 : 7 0 8 9 10 11 12
+ Tuple #1 : 0 0 0 0 0 0 0
+ Tuple #2 : 7 0 8 9 10 11 12
+ Tuple #3 : 0 0 0 0 0 0 0
+</pre>
+\note \ref ParaMEDMEM::DataArrayDouble::setPartOfValues3() can't
+be explicitly called in Python.
+
+
+\anchor cpp_mcdataarrayint_setselectedcomponents
+<br><h2> Set part of values of DataArrayInt </h2>
+<h3> setSelectedComponents() </h3>
+First, we create a 'source' array.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setSelectedComponents1
+Now we create a larger zero array and assign the array \b da to it.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setSelectedComponents2
+As result contents of the array \b dv are as follows.
+<pre>
+Info of components : "a2" "a1" "v3" "v4"
+ Tuple #0 : 2 1 0 0
+ Tuple #1 : 4 3 0 0
+ Tuple #2 : 6 5 0 0
+ Tuple #3 : 0 0 0 0
+</pre>
+The same result can be achieved other way (except that component info
+is not copied):
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setSelectedComponents3
+
+\anchor cpp_mcdataarrayint_setpartofvalues1
+<br><h3> setPartOfValues1() </h3>
+We create two arrays:
+- a "large" (4x4) zero array \b da to assign to and
+- a smaller (2x2) array \b dv filled with values [7,8,9,10].
+
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_1
+Now we copy \b dv to the middle of \b da.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_2
+As result contents of the array \b da are as follows.
+<pre>
+ Info of components :"v1" "v2" "v3" "v4"
+ Tuple #0 : 0 0 0 0
+ Tuple #1 : 0 7 8 0
+ Tuple #2 : 0 9 10 0
+ Tuple #3 : 0 0 0 0
+</pre>
+
+Here we re-fill \b da with zeros and copy \b dv into a component of \b da.
+
+Note that the last parameter \a strictCompoCompare should be \a False
+in this case, else \ref ParaMEDMEM::DataArrayInt::setPartOfValues1()
+throws an exception because \b da has 2 components but only one target
+component is specified.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_3
+<pre>
+ Tuple #0 : 0 7 0 0
+ Tuple #1 : 0 8 0 0
+ Tuple #2 : 0 9 0 0
+ Tuple #3 : 0 10 0 0
+</pre>
+Below more two variants of location of target values are shown.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_4
+<pre>
+ Tuple #0 : 0 0 0 0
+ Tuple #1 : 7 8 9 10
+ Tuple #2 : 0 0 0 0
+ Tuple #3 : 0 0 0 0
+</pre>
+
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_5
+<pre>
+ Tuple #0 : 0 7 0 8
+ Tuple #1 : 0 0 0 0
+ Tuple #2 : 0 9 0 10
+ Tuple #3 : 0 0 0 0
+</pre>
+The same result can be achieved other way:
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_6
+
+
+
+\anchor cpp_mcdataarrayint_setpartofvaluessimple1
+<br><h3> setPartOfValuesSimple1() </h3>
+We create an array (4x4) \b da to assign to and define a value \b dv to assign.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_1
+Now we assign \b dv to the middle of \b da.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_2
+As result contents of the array \b da are as follows.
+<pre>
+ Tuple #0 : 0 0 0 0
+ Tuple #1 : 0 7 7 0
+ Tuple #2 : 0 7 7 0
+ Tuple #3 : 0 0 0 0
+</pre>
+
+Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_3
+<pre>
+ Tuple #0 : 0 7 0 0
+ Tuple #1 : 0 7 0 0
+ Tuple #2 : 0 7 0 0
+ Tuple #3 : 0 7 0 0
+</pre>
+Below more two variants of location of target values are shown.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_4
+<pre>
+ Tuple #0 : 0 0 0 0
+ Tuple #1 : 7 7 7 7
+ Tuple #2 : 0 0 0 0
+ Tuple #3 : 0 0 0 0
+</pre>
+
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_5
+<pre>
+ Tuple #0 : 0 7 0 7
+ Tuple #1 : 0 0 0 0
+ Tuple #2 : 0 7 0 7
+ Tuple #3 : 0 0 0 0
+</pre>
+The same result can be achieved other way:
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_6
+
+
+\anchor cpp_mcdataarrayint_setpartofvaluessimple2
+<br><h3> setPartOfValuesSimple2() </h3>
+We create an array (4x4) \b da to assign to and define a value \b dv to assign.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_1
+Now we assign \b dv to the middle of \b da.
+We explicitly specify tuples and component to assign to by a list [1,2].
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_2
+As result contents of the array \b da are as follows.
+<pre>
+ Tuple #0 : 0 0 0 0
+ Tuple #1 : 0 7 7 0
+ Tuple #2 : 0 7 7 0
+ Tuple #3 : 0 0 0 0
+</pre>
+
+Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_3
+<pre>
+ Tuple #0 : 0 7 0 0
+ Tuple #1 : 0 7 0 0
+ Tuple #2 : 0 7 0 0
+ Tuple #3 : 0 7 0 0
+</pre>
+Below more two variants of location of target values are shown.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_4
+<pre>
+ Tuple #0 : 0 0 0 0
+ Tuple #1 : 7 7 7 7
+ Tuple #2 : 0 0 0 0
+ Tuple #3 : 0 0 0 0
+</pre>
+
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_5
+<pre>
+ Tuple #0 : 0 7 0 7
+ Tuple #1 : 0 0 0 0
+ Tuple #2 : 0 7 0 7
+ Tuple #3 : 0 0 0 0
+</pre>
+\note \ref ParaMEDMEM::DataArrayInt::setPartOfValuesSimple2() can't
+be explicitly called in Python.
+
+
+\anchor cpp_mcdataarrayint_setpartofvaluessimple3
+<br><h3> setPartOfValuesSimple3() </h3>
+We create an array (4x4) \b da to assign to and define a value \b dv to assign.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_1
+Now we assign \b dv to the middle of \b da.
+We explicitly specify tuples to assign to by a list [1,2]. And we specify
+components to assign to using slicing: 1:3.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_2
+As result contents of the array \b da are as follows.
+<pre>
+ Tuple #0 : 0 0 0 0
+ Tuple #1 : 0 7 7 0
+ Tuple #2 : 0 7 7 0
+ Tuple #3 : 0 0 0 0
+</pre>
+
+Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_3
+<pre>
+ Tuple #0 : 0 7 0 0
+ Tuple #1 : 0 7 0 0
+ Tuple #2 : 0 7 0 0
+ Tuple #3 : 0 7 0 0
+</pre>
+Below more two variants of location of target values are shown.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_4
+<pre>
+ Tuple #0 : 0 0 0 0
+ Tuple #1 : 7 7 7 7
+ Tuple #2 : 0 0 0 0
+ Tuple #3 : 0 0 0 0
+</pre>
+
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_5
+<pre>
+ Tuple #0 : 0 7 0 7
+ Tuple #1 : 0 0 0 0
+ Tuple #2 : 0 7 0 7
+ Tuple #3 : 0 0 0 0
+</pre>
+\note \ref ParaMEDMEM::DataArrayInt::setPartOfValuesSimple3() can't
+be explicitly called in Python.
+
+
+\anchor cpp_mcdataarrayint_setpartofvalues2
+<br><h3> setPartOfValues2() </h3>
+We create two arrays:
+- a "large" (4x7) zero array \b da to assign to,
+- a smaller (3x2) array \b dv filled with values [7,8,9,10,11,12].
+
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues2_1
+Now we assign the two components of \b dv to the components of \b da
+with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
+ indices [0,1,2]. This is the first mode of usage.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues2_2
+As result contents of the array \b da are as follows.
+<pre>
+ Tuple #0 : 0 7 0 8 0 0 0
+ Tuple #1 : 0 9 0 10 0 0 0
+ Tuple #2 : 0 11 0 12 0 0 0
+ Tuple #3 : 0 0 0 0 0 0 0
+</pre>
+Every value of \b dv has been assigned to its own location within \b da.
+
+Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
+And we assign \b dv to the tuples of \b da with indices [0,2,3] .
+This is the second mode of usage.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues2_3
+The contents of \b dv have been assigned to each of specified tuples of \b da.
+Every value of \b dv is repeated in the 3 specified tuples within \b da.
+<pre>
+ Tuple #0 : 7 0 8 9 10 11 12
+ Tuple #1 : 0 0 0 0 0 0 0
+ Tuple #2 : 7 0 8 9 10 11 12
+ Tuple #3 : 7 0 8 9 10 11 12
+</pre>
+\note \ref ParaMEDMEM::DataArrayInt::setPartOfValues2() can't
+be explicitly called in Python.
+
+
+\anchor cpp_mcdataarrayint_setpartofvalues3
+<br><h3> setPartOfValues3() </h3>
+We create two arrays:
+- a "large" (4x7) zero array \b da to assign to,
+- a smaller (3x2) array \b dv filled with values [7,8,9,10,11,12].
+
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues3_1
+Now we assign the two components of \b dv to the components of \b da
+with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
+indices [0,1,2] which are specified using slicing: "0:3".
+This is the first mode of usage.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues3_2
+As result contents of the array \b da are as follows.
+<pre>
+ Tuple #0 : 0 7 0 8 0 0 0
+ Tuple #1 : 0 9 0 10 0 0 0
+ Tuple #2 : 0 11 0 12 0 0 0
+ Tuple #3 : 0 0 0 0 0 0 0
+</pre>
+Every value of \b dv has been assigned to its own location within \b da.
+
+Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
+And we assign \b dv to the tuples of \b da with indices [0,2] using \a
+slice notation "0:4:2". This is the second mode of usage.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues3_3
+The contents of \b dv have been assigned to each of specified tuples of \b da.
+Every value of \b dv is repeated in the 3 specified tuples within \b da.
+<pre>
+ Tuple #0 : 7 0 8 9 10 11 12
+ Tuple #1 : 0 0 0 0 0 0 0
+ Tuple #2 : 7 0 8 9 10 11 12
+ Tuple #3 : 0 0 0 0 0 0 0
+</pre>
+\note \ref ParaMEDMEM::DataArrayInt::setPartOfValues3() can't
+be explicitly called in Python.
+
+
+\anchor cpp_mcdataarraydouble_getdifferentvalues
+<br><h2> Excluding coincident tuples from DataArrayDouble</h2>
+
+The code below creates an array of real values and than an array of
+ unique values, not closer one to another than 0.2, is retrieved from it.
+\snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_getDifferentValues1
+
+
+\anchor cpp_mcdataarraydouble_findcommontuples
+<br><h2> Finding coincident tuples in DataArrayDouble</h2>
+
+Let's create an array of 6 tuples and 2 components that can be
+ considered as coordinates of 6 points in 2D space.
+\snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_findCommonTuples1
+Now we find points that are not far each from other than 1e-1.
+\snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_findCommonTuples2
+As we can realize from the above code, a hardcoded array \b expected3 is equal
+ to the raw data of a DataArrayInt \b c and a hardcoded array \b expected4 is equal
+ to the raw data of the DataArrayInt \b cI.
+
+The array \b c contains indices of 5 coincident points. The array \b
+ cI shows us boundaries of (cI->getNumberOfTuples()-1) = 2 groups of coincident points:
+- The first group starts at index 0 and includes (3 - 0) = 3 points: 0,3,4.
+- The second group starts at index 3 and includes (5 - 3) = 2 points: 1,2.
+
+\anchor cpp_mcdataarraydouble_meldwith
+<br><h2> Concatenating DataArrayDouble's by appending components </h2>
+
+In this example we create two data arrays including \b same number of
+tuples and then we concatenate them using \ref
+ParaMEDMEM::DataArrayDouble::meldWith "meldWith()".
+\snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_Meld1_1
+Now the array \b da1 includes 7 tuples (as before) of 3 components
+each. Its components are: "c0da1","c1da1","c0da2".
+
+
+\anchor cpp_mcdataarrayint_meldwith
+<br><h2> Concatenating DataArrayInt's by appending components </h2>
+
+In this example we create two data arrays including \b same number of
+tuples and then we concatenate them using \ref
+ParaMEDMEM::DataArrayInt::meldWith "meldWith()".
+\snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_Meld1_1
+Now the array \b da1 includes 7 tuples (as before) of 3 components
+each. Its components are: "c0da1","c1da1","c0da2".
+
+
+\anchor cpp_mcdataarraydouble_KeepSelectedComponents
+
+<br><h2>Creation of a sub-part of the DataArrayDouble by selecting components</h2>
+
+\snippet MEDCouplingExamplesTest.py SnippeDataArrayDoubleKeepSelectedComponents1_1
+We created an array \b a1 containing 5 tuples of 4 components each (20
+values). Now we are going to create an array \b a2 containing some
+components of \b a1.
+\snippet MEDCouplingExamplesTest.py SnippeDataArrayDoubleKeepSelectedComponents1_2
+Now each tuple of \b a2 includes components named "b","c","b","c","a","a". Thus
+the result array \b a2 includes 30 elements (5 tuples per 6 components).
+
\anchor cpp_mcfielddouble_subpart1
+
+\anchor cpp_mcdataarrayint_keepselectedcomponents
+
+<br><h2>Creation of a sub-part of the DataArrayInt by selecting components</h2>
+
+\snippet MEDCouplingExamplesTest.py SnippeDataArrayIntKeepSelectedComponents1_1
+We created an array \b a1 containing 5 tuples of 4 components each (20
+values). Now we are going to create an array \b a2 containing some
+components of \b a1.
+\snippet MEDCouplingExamplesTest.py SnippeDataArrayIntKeepSelectedComponents1_2
+Now each tuple of \b a2 includes components named "b","c","b","c","a","a". Thus
+the result array \b a2 includes 30 elements (5 tuples per 6 components).
+
+Note that
+\ref ParaMEDMEM::DataArrayInt::keepSelectedComponents() "DataArrayInt::keepSelectedComponents()"
+is called, providing the same result, by the following python code:
+\snippet MEDCouplingExamplesTest.py SnippeDataArrayIntKeepSelectedComponents1_3
+
+\anchor cpp_mcfielddouble_subpart1
+
+
<br><h2>Creation of a sub part of a field</h2>
<br><h3>Creation of a sub part of a field on cells</h3>
\snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_1
-The field on cells \b f1 lies on a mesh containg 5 cells and 9 nodes.
+The field on cells \b f1 lies on a mesh containing 5 cells and 9 nodes.
So this field \b f1 contains 5 tuples of 2 components each (10 values).
Now let's create a subfield on cells \b f2 from \b f1.
\snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_2
<br><h3>Creation of a sub part of a field on nodes</h3>
\snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_3
-The field on nodes \b f1 lies on a mesh containg 5 cells and 9 nodes.
+The field on nodes \b f1 lies on a mesh containing 5 cells and 9 nodes.
So this field \b f1 contains 9 tuples of 2 components each (18 values).
Now let's create a subfield on nodes \b f2 from \b f1.
\snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_4
\snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_4
-At this level mesh is usable. When this mesh is no more needed simply call decrRef to decrement its reference counter.
+At this level mesh is usable. When this mesh is no more needed simply call decrRef() to decrement its reference counter.
\snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_5
Then create ParaMEDMEM::MEDCouplingCMesh instance giving the 2 instances of \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble" obtained above.
-There are 2 technics to get it.
+There are 2 techniques to get it.
Either :
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>$title</title>
<link href="$relpath$tabs.css" rel="stylesheet" type="text/css"/>
+<script type="text/javascript" src="$relpath^jquery.js"></script>
+<script type="text/javascript" src="$relpath^dynsections.js"></script>
$treeview
$search
$mathjax
\param elems array to the indices of the elements contained in the BBTree
\param level level in the BBTree recursive structure
\param nbelems nb of elements in the BBTree
- \param epsilon precision to which points are decided to be coincident
+ \param epsilon precision to which points are decided to be coincident. Epsilon can be positive or negative.
+ If \a epsilon is positive the request method will enlarge the computed bounding box (more matching elems return).
+ If negative the given bounding box will be tighten (less matching elems return).
Parameters \a elems and \a level are used only by BBTree itself for creating trees recursively. A typical use is therefore :
\code
\endcode
*/
- BBTree(const double* bbs, ConnType* elems, int level, ConnType nbelems, double epsilon=1E-12):
+ BBTree(const double* bbs, ConnType* elems, int level, ConnType nbelems, double epsilon=1e-12):
_left(0), _right(0), _level(level), _bb(bbs), _terminal(false),_nbelems(nbelems),_epsilon(epsilon)
{
if (nbelems < MIN_NB_ELEMS || level> MAX_LEVEL)
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __BBTREEPTS_TXX__
+#define __BBTREEPTS_TXX__
+
+#include <vector>
+#include <algorithm>
+
+#include <iostream>
+#include <limits>
+#include <cmath>
+
+template <int dim, class ConnType = int>
+class BBTreePts
+{
+
+private:
+ BBTreePts* _left;
+ BBTreePts* _right;
+ int _level;
+ double _max_left;
+ double _min_right;
+ const double *_pts;
+ typename std::vector<ConnType> _elems;
+ bool _terminal;
+ ConnType _nbelems;
+ double _epsilon;
+
+ static const int MIN_NB_ELEMS=15;
+ static const int MAX_LEVEL=20;
+public:
+
+ /*!
+ Constructor of the bounding box tree
+ \param [in] pts pointer to the array containing the points that are to be indexed.
+ \param [in] elems array to the indices of the elements contained in the BBTreePts
+ \param [in] level level in the BBTreePts recursive structure
+ \param [in] nbelems nb of elements in the BBTreePts
+ \param [in] epsilon precision to which points are decided to be coincident. Contrary to BBTree, the absolute epsilon is computed. So the internal epsilon is always positive.
+
+ Parameters \a elems and \a level are used only by BBTreePts itself for creating trees recursively. A typical use is therefore :
+ \code
+ int nbelems=...
+ double* pts= new double[dim*nbelems];
+ // filling pts ...
+ ...
+ BBTreePts<2> tree = new BBTreePts<2>(elems,0,0,nbelems,1e-12);
+ \endcode
+ */
+ BBTreePts(const double *pts, const ConnType *elems, int level, ConnType nbelems, double epsilon=1e-12):
+ _left(0),_right(0),_level(level),_pts(pts),_terminal(nbelems < MIN_NB_ELEMS || level> MAX_LEVEL),_nbelems(nbelems),_epsilon(std::abs(epsilon))
+ {
+ double *nodes=new double[nbelems];
+ _elems.resize(nbelems);
+ for (ConnType i=0;i<nbelems;i++)
+ {
+ ConnType elem;
+ if (elems!=0)
+ elem= elems[i];
+ else
+ elem=i;
+
+ _elems[i]=elem;
+ nodes[i]=pts[elem*dim+(level%dim)];
+ }
+ if(_terminal) { delete[] nodes; return; }
+ //
+ std::nth_element<double*>(nodes, nodes+nbelems/2, nodes+nbelems);
+ double median=*(nodes+nbelems/2);
+ delete [] nodes;
+ std::vector<ConnType> new_elems_left,new_elems_right;
+
+ new_elems_left.reserve(nbelems/2+1);
+ new_elems_right.reserve(nbelems/2+1);
+ double max_left = -std::numeric_limits<double>::max();
+ double min_right= std::numeric_limits<double>::max();
+ for(int i=0;i<nbelems;i++)
+ {
+ int elem;
+ if(elems!=0)
+ elem= elems[i];
+ else
+ elem=i;
+ double mx=pts[elem*dim+(level%dim)];
+ if(mx>median)
+ {
+ new_elems_right.push_back(elem);
+ if(mx<min_right) min_right=mx;
+ }
+ else
+ {
+ new_elems_left.push_back(elem);
+ if(mx>max_left) max_left=mx;
+ }
+ }
+ _max_left=max_left+_epsilon;
+ _min_right=min_right-_epsilon;
+ ConnType *tmp;
+ tmp=0;
+ if(!new_elems_left.empty())
+ tmp=&(new_elems_left[0]);
+ _left=new BBTreePts(pts, tmp, level+1, (int)new_elems_left.size(),_epsilon);
+ tmp=0;
+ if(!new_elems_right.empty())
+ tmp=&(new_elems_right[0]);
+ _right=new BBTreePts(pts, tmp, level+1, (int)new_elems_right.size(),_epsilon);
+ }
+
+
+
+ ~BBTreePts()
+ {
+ delete _left;
+ delete _right;
+ }
+
+ /*! returns in \a elems the list of elements potentially containing the point pointed to by \a xx
+ Contrary to BBTreePts::getElementsAroundPoint the norm 2 is used here.
+
+ \param [in] xx pointer to query point coords
+ \param [in] threshold
+ \param elems list of elements (given in 0-indexing) intersecting the bounding box
+ \sa BBTreePts::getElementsAroundPoint
+ */
+ double getElementsAroundPoint2(const double *xx, double threshold, ConnType& elem) const
+ {
+ // terminal node : return list of elements intersecting bb
+ if(_terminal)
+ {
+ double ret=std::numeric_limits<double>::max();
+ for(ConnType i=0;i<_nbelems;i++)
+ {
+ const double* const bb_ptr=_pts+_elems[i]*dim;
+ double tmp=0.;
+ for(int idim=0;idim<dim;idim++)
+ tmp+=(bb_ptr[idim]-xx[idim])*(bb_ptr[idim]-xx[idim]);
+ if(tmp<threshold)
+ {
+ if(tmp<ret)
+ { ret=tmp; elem=_elems[i]; }
+ }
+ }
+ return ret;
+ }
+ //non terminal node
+ double s=sqrt(threshold*dim);
+ if(xx[_level%dim]+s<_min_right)
+ return _left->getElementsAroundPoint2(xx,threshold,elem);
+ if(xx[_level%dim]-s>_max_left)
+ return _right->getElementsAroundPoint2(xx,threshold,elem);
+ int eleml,elemr;
+ double retl=_left->getElementsAroundPoint2(xx,threshold,eleml);
+ double retr=_right->getElementsAroundPoint2(xx,threshold,elemr);
+ if(retl<retr)
+ { elem=eleml; return retl; }
+ else
+ { elem=elemr; return retr; }
+ }
+
+ /*! returns in \a elems the list of elements potentially containing the point pointed to by \a xx
+ \param xx pointer to query point coords
+ \param elems list of elements (given in 0-indexing) intersecting the bounding box
+ \sa BBTreePts::getElementsAroundPoint2
+ */
+ void getElementsAroundPoint(const double* xx, std::vector<ConnType>& elems) const
+ {
+ // terminal node : return list of elements intersecting bb
+ if(_terminal)
+ {
+ for(ConnType i=0;i<_nbelems;i++)
+ {
+ const double* const bb_ptr=_pts+_elems[i]*dim;
+ bool intersects = true;
+ for(int idim=0;idim<dim;idim++)
+ if(std::abs(bb_ptr[idim]-xx[idim])>_epsilon)
+ intersects=false;
+ if(intersects)
+ elems.push_back(_elems[i]);
+ }
+ return;
+ }
+ //non terminal node
+ if(xx[_level%dim]<_min_right)
+ {
+ _left->getElementsAroundPoint(xx,elems);
+ return;
+ }
+ if(xx[_level%dim]>_max_left)
+ {
+ _right->getElementsAroundPoint(xx,elems);
+ return;
+ }
+ _left->getElementsAroundPoint(xx,elems);
+ _right->getElementsAroundPoint(xx,elems);
+ }
+
+ int size() const
+ {
+ if(_terminal)
+ return _nbelems;
+ return _left->size()+_right->size();
+ }
+};
+
+#endif
_reverse_extruded_type=NORM_ERROR;
_linear_type=NORM_ERROR;
_quadratic_type=NORM_ERROR;
+ _quadratic_type2=NORM_ERROR;
_nb_of_little_sons=std::numeric_limits<unsigned>::max();
switch(type)
{
break;
case NORM_SEG2:
{
- _nb_of_pts=2; _nb_of_sons=2; _dim=1; _extruded_type=NORM_QUAD4; _quadratic_type=NORM_SEG3; _is_simplex=true; _is_extruded=true; _reverse_extruded_type=NORM_POINT1;
+ _nb_of_pts=2; _nb_of_sons=2; _dim=1; _extruded_type=NORM_QUAD4; _quadratic_type=NORM_SEG3; _quadratic_type2=NORM_SEG3; _is_simplex=true; _is_extruded=true; _reverse_extruded_type=NORM_POINT1;
_sons_type[0]=NORM_POINT1; _sons_type[1]=NORM_POINT1;
_sons_con[0][0]=0; _nb_of_sons_con[0]=1;
_sons_con[1][0]=1; _nb_of_sons_con[1]=1;
break;
case NORM_HEXA8:
{
- _nb_of_pts=8; _nb_of_sons=6; _dim=3; _quadratic_type=NORM_HEXA20; _is_simplex=false; _is_extruded=true; _reverse_extruded_type=NORM_QUAD4;
+ _nb_of_pts=8; _nb_of_sons=6; _dim=3; _quadratic_type=NORM_HEXA20; _quadratic_type2=NORM_HEXA27; _is_simplex=false; _is_extruded=true; _reverse_extruded_type=NORM_QUAD4;
_sons_type[0]=NORM_QUAD4; _sons_type[1]=NORM_QUAD4; _sons_type[2]=NORM_QUAD4; _sons_type[3]=NORM_QUAD4; _sons_type[4]=NORM_QUAD4; _sons_type[5]=NORM_QUAD4;
_sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=3; _nb_of_sons_con[0]=4;
_sons_con[1][0]=4; _sons_con[1][1]=7; _sons_con[1][2]=6; _sons_con[1][3]=5; _nb_of_sons_con[1]=4;
break;
case NORM_QUAD4:
{
- _nb_of_pts=4; _nb_of_sons=4; _dim=2; _quadratic_type=NORM_QUAD8; _is_simplex=false; _is_extruded=true;
+ _nb_of_pts=4; _nb_of_sons=4; _dim=2; _quadratic_type=NORM_QUAD8; _quadratic_type2=NORM_QUAD9; _is_simplex=false; _is_extruded=true;
_sons_type[0]=NORM_SEG2; _sons_type[1]=NORM_SEG2; _sons_type[2]=NORM_SEG2; _sons_type[3]=NORM_SEG2;
_sons_con[0][0]=0; _sons_con[0][1]=1; _nb_of_sons_con[0]=2;
_sons_con[1][0]=1; _sons_con[1][1]=2; _nb_of_sons_con[1]=2;
break;
case NORM_TRI3:
{
- _nb_of_pts=3; _nb_of_sons=3; _dim=2; _quadratic_type=NORM_TRI6; _is_simplex=true;
+ _nb_of_pts=3; _nb_of_sons=3; _dim=2; _quadratic_type=NORM_TRI6; _quadratic_type2=NORM_TRI7; _is_simplex=true;
_sons_type[0]=NORM_SEG2; _sons_type[1]=NORM_SEG2; _sons_type[2]=NORM_SEG2;
_sons_con[0][0]=0; _sons_con[0][1]=1; _nb_of_sons_con[0]=2;
_sons_con[1][0]=1; _sons_con[1][1]=2; _nb_of_sons_con[1]=2;
_sons_con[1][0]=0; _sons_con[1][1]=3; _sons_con[1][2]=1; _sons_con[1][3]=7; _sons_con[1][4]=8; _sons_con[1][5]=4; _nb_of_sons_con[1]=6;
_sons_con[2][0]=1; _sons_con[2][1]=3; _sons_con[2][2]=2; _sons_con[2][3]=8; _sons_con[2][4]=9; _sons_con[2][5]=5; _nb_of_sons_con[2]=6;
_sons_con[3][0]=2; _sons_con[3][1]=3; _sons_con[3][2]=0; _sons_con[3][3]=9; _sons_con[3][4]=7; _sons_con[3][5]=6; _nb_of_sons_con[3]=6; _quadratic=true;
- _little_sons_con[0][0]=0; _little_sons_con[0][1]=1; _little_sons_con[0][2]=4; _nb_of_little_sons=6;
+ _little_sons_con[0][0]=0; _little_sons_con[0][1]=1; _little_sons_con[0][2]=4; _nb_of_little_sons=6;
_little_sons_con[1][0]=1; _little_sons_con[1][1]=2; _little_sons_con[1][2]=5;
_little_sons_con[2][0]=2; _little_sons_con[2][1]=0; _little_sons_con[2][2]=6;
_little_sons_con[3][0]=0; _little_sons_con[3][1]=3; _little_sons_con[3][2]=7;
_sons_con[2][0]=1; _sons_con[2][1]=4; _sons_con[2][2]=2; _sons_con[2][3]=10; _sons_con[2][4]=11; _sons_con[2][5]=6; _nb_of_sons_con[2]=6;
_sons_con[3][0]=2; _sons_con[3][1]=4; _sons_con[3][2]=3; _sons_con[3][3]=11; _sons_con[3][4]=12; _sons_con[3][5]=7; _nb_of_sons_con[3]=6;
_sons_con[4][0]=3; _sons_con[4][1]=4; _sons_con[4][2]=0; _sons_con[4][3]=12; _sons_con[4][4]=9; _sons_con[4][5]=8; _nb_of_sons_con[4]=6; _quadratic=true;
- _little_sons_con[0][0]=0; _little_sons_con[0][1]=1; _little_sons_con[0][2]=5; _nb_of_little_sons=8;
+ _little_sons_con[0][0]=0; _little_sons_con[0][1]=1; _little_sons_con[0][2]=5; _nb_of_little_sons=8;
_little_sons_con[1][0]=1; _little_sons_con[1][1]=2; _little_sons_con[1][2]=6;
_little_sons_con[2][0]=2; _little_sons_con[2][1]=3; _little_sons_con[2][2]=7;
_little_sons_con[3][0]=3; _little_sons_con[3][1]=0; _little_sons_con[3][2]=8;
_sons_con[2][0]=0; _sons_con[2][1]=3; _sons_con[2][2]=4; _sons_con[2][3]=1; _sons_con[2][4]=12; _sons_con[2][5]=9; _sons_con[2][6]=13; _sons_con[2][7]=6; _nb_of_sons_con[2]=8;
_sons_con[3][0]=1; _sons_con[3][1]=4; _sons_con[3][2]=5; _sons_con[3][3]=2; _sons_con[3][4]=13; _sons_con[3][5]=10; _sons_con[3][6]=14; _sons_con[3][7]=7; _nb_of_sons_con[3]=8;
_sons_con[4][0]=2; _sons_con[4][1]=4; _sons_con[4][2]=5; _sons_con[4][3]=0; _sons_con[4][4]=14; _sons_con[4][5]=11; _sons_con[4][6]=12; _sons_con[4][7]=8; _nb_of_sons_con[4]=8; _quadratic=true;
- _little_sons_con[0][0]=0; _little_sons_con[0][1]=1; _little_sons_con[0][2]=6; _nb_of_little_sons=9;
+ _little_sons_con[0][0]=0; _little_sons_con[0][1]=1; _little_sons_con[0][2]=6; _nb_of_little_sons=9;
_little_sons_con[1][0]=1; _little_sons_con[1][1]=2; _little_sons_con[1][2]=7;
_little_sons_con[2][0]=2; _little_sons_con[2][1]=0; _little_sons_con[2][2]=8;
_little_sons_con[3][0]=3; _little_sons_con[3][1]=4; _little_sons_con[3][2]=9;
_sons_con[3][0]=1; _sons_con[3][1]=5; _sons_con[3][3]=6; _sons_con[3][3]=2; _sons_con[3][4]=17; _sons_con[3][5]=13; _sons_con[3][6]=18; _sons_con[3][7]=9;_nb_of_sons_con[3]=8;
_sons_con[4][0]=2; _sons_con[4][1]=6; _sons_con[4][3]=7; _sons_con[4][3]=3; _sons_con[4][4]=18; _sons_con[4][5]=14; _sons_con[4][6]=19; _sons_con[4][7]=10; _nb_of_sons_con[4]=8;
_sons_con[5][0]=3; _sons_con[5][1]=7; _sons_con[5][3]=4; _sons_con[5][3]=0; _sons_con[5][4]=19; _sons_con[5][5]=15; _sons_con[5][6]=16; _sons_con[5][7]=11; _nb_of_sons_con[5]=8; _quadratic=true;
- _little_sons_con[0][0]=0; _little_sons_con[0][1]=1; _little_sons_con[0][2]=8; _nb_of_little_sons=12;
+ _little_sons_con[0][0]=0; _little_sons_con[0][1]=1; _little_sons_con[0][2]=8; _nb_of_little_sons=12;
_little_sons_con[1][0]=1; _little_sons_con[1][1]=2; _little_sons_con[1][2]=9;
_little_sons_con[2][0]=2; _little_sons_con[2][1]=3; _little_sons_con[2][2]=10;
_little_sons_con[3][0]=3; _little_sons_con[3][1]=0; _little_sons_con[3][2]=11;
throw INTERP_KERNEL::Exception("CellModel::fillSonCellNodalConnectivity2 : no sons on NORM_POLYL !");
}
}
+
+ /*!
+ * Equivalent to CellModel::fillSonCellNodalConnectivity2 except for HEXA8 where the order of sub faces is not has MED file numbering for transformation HEXA8->HEXA27
+ */
+ unsigned CellModel::fillSonCellNodalConnectivity4(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, NormalizedCellType& typeOfSon) const
+ {
+ if(_type==NORM_HEXA8)
+ {
+ static const int permutation[6]={0,2,3,4,1};
+ return fillSonCellNodalConnectivity2(permutation[sonId],nodalConn,lgth,sonNodalConn,typeOfSon);
+ }
+ else
+ return fillSonCellNodalConnectivity2(sonId,nodalConn,lgth,sonNodalConn,typeOfSon);
+ }
unsigned CellModel::fillSonEdgesNodalConnectivity3D(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, NormalizedCellType& typeOfSon) const
{
if(!isDynamic())
{
- if(!isQuadratic())
- {
- typeOfSon=NORM_SEG2;
- sonNodalConn[0]=nodalConn[_little_sons_con[sonId][0]];
- sonNodalConn[1]=nodalConn[_little_sons_con[sonId][1]];
- return 2;
- }
- else
- {
- typeOfSon=NORM_SEG3;
- sonNodalConn[0]=nodalConn[_little_sons_con[sonId][0]];
- sonNodalConn[1]=nodalConn[_little_sons_con[sonId][1]];
- sonNodalConn[2]=nodalConn[_little_sons_con[sonId][2]];
- return 3;
- }
+ if(!isQuadratic())
+ {
+ typeOfSon=NORM_SEG2;
+ sonNodalConn[0]=nodalConn[_little_sons_con[sonId][0]];
+ sonNodalConn[1]=nodalConn[_little_sons_con[sonId][1]];
+ return 2;
+ }
+ else
+ {
+ typeOfSon=NORM_SEG3;
+ sonNodalConn[0]=nodalConn[_little_sons_con[sonId][0]];
+ sonNodalConn[1]=nodalConn[_little_sons_con[sonId][1]];
+ sonNodalConn[2]=nodalConn[_little_sons_con[sonId][2]];
+ return 3;
+ }
}
else
throw INTERP_KERNEL::Exception("CellModel::fillSonEdgesNodalConnectivity3D : not implemented yet for NORM_POLYHED !");
INTERPKERNEL_EXPORT NormalizedCellType getReverseExtrudedType() const { return _reverse_extruded_type; }
INTERPKERNEL_EXPORT NormalizedCellType getLinearType() const { return _linear_type; }
INTERPKERNEL_EXPORT NormalizedCellType getQuadraticType() const { return _quadratic_type; }
+ INTERPKERNEL_EXPORT NormalizedCellType getQuadraticType2() const { return _quadratic_type2; }
INTERPKERNEL_EXPORT NormalizedCellType getSonType(unsigned sonId) const { return _sons_type[sonId]; }
INTERPKERNEL_EXPORT NormalizedCellType getSonType2(unsigned sonId) const;
INTERPKERNEL_EXPORT unsigned fillSonCellNodalConnectivity(int sonId, const int *nodalConn, int *sonNodalConn) const;
INTERPKERNEL_EXPORT unsigned fillSonCellNodalConnectivity2(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, NormalizedCellType& typeOfSon) const;
+ INTERPKERNEL_EXPORT unsigned fillSonCellNodalConnectivity4(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, NormalizedCellType& typeOfSon) const;
INTERPKERNEL_EXPORT unsigned fillSonEdgesNodalConnectivity3D(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, NormalizedCellType& typeOfSon) const;
private:
bool _dyn;
NormalizedCellType _reverse_extruded_type;
NormalizedCellType _linear_type;
NormalizedCellType _quadratic_type;
+ NormalizedCellType _quadratic_type2;
unsigned _sons_con[MAX_NB_OF_SONS][MAX_NB_OF_NODES_PER_ELEM];
unsigned _little_sons_con[MAX_NB_OF_LITTLE_SONS][3];
unsigned _nb_of_sons_con[MAX_NB_OF_SONS];
int fromIntegralUniform(const MyMeshType& meshT, MatrixType& result, const char *method) { return fromToIntegralUniform(false,meshT,result,method); }
template<class MyMeshType, class MatrixType>
int toIntegralUniform(const MyMeshType& meshS, MatrixType& result, const char *method) { return fromToIntegralUniform(true,meshS,result,method); }
- static void checkAndSplitInterpolationMethod(const char *method, std::string& srcMeth, std::string& trgMeth) throw(INTERP_KERNEL::Exception);
+ static void CheckAndSplitInterpolationMethod(const char *method, std::string& srcMeth, std::string& trgMeth) throw(INTERP_KERNEL::Exception);
template<class MyMeshType>
static double CalculateCharacteristicSizeOfMeshes(const MyMeshType& myMeshS, const MyMeshType& myMeshT, const int printLevel);
protected:
}
template<class TrueMainInterpolator>
- void Interpolation<TrueMainInterpolator>::checkAndSplitInterpolationMethod(const char *method, std::string& srcMeth, std::string& trgMeth) throw(INTERP_KERNEL::Exception)
+ void Interpolation<TrueMainInterpolator>::CheckAndSplitInterpolationMethod(const char *method, std::string& srcMeth, std::string& trgMeth) throw(INTERP_KERNEL::Exception)
{
const int NB_OF_METH_MANAGED=4;
const char *METH_MANAGED[NB_OF_METH_MANAGED]={"P0P0","P0P1","P1P0","P1P1"};
found=(methodC==METH_MANAGED[i]);
if(!found)
{
- std::string msg("The interpolation method : \'"); msg+=method; msg+="\' not managed !";
+ std::string msg("The interpolation method : \'"); msg+=method; msg+="\' not managed by INTERP_KERNEL interpolators ! Supported are \"P0P0\", \"P0P1\", \"P1P0\" and \"P1P1\".";
throw INTERP_KERNEL::Exception(msg.c_str());
}
srcMeth=methodC.substr(0,2);
salomeinclude_HEADERS = \
BBTree.txx \
+BBTreePts.txx \
BoundingBox.hxx \
CellModel.hxx \
ConvexIntersector.hxx \
void MEDCouplingCurveLinearMesh::translate(const double *vector)
{
+ if(!vector)
+ throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::translate : NULL input point !");
if(!((DataArrayDouble *)_coords))
throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::translate : no coordinates set !");
double *coords=_coords->getPointer();
void MEDCouplingCurveLinearMesh::scale(const double *point, double factor)
{
+ if(!point)
+ throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::scale : NULL input point !");
if(!((DataArrayDouble *)_coords))
throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::scale : no coordinates set !");
double *coords=_coords->getPointer();
{
}
-MEDCouplingField::MEDCouplingField(const MEDCouplingField& other):RefCountObject(other),_name(other._name),_desc(other._desc),_nature(other._nature),
- _mesh(0),_type(other._type->clone())
+MEDCouplingField::MEDCouplingField(const MEDCouplingField& other, bool deepCopy):RefCountObject(other),_name(other._name),_desc(other._desc),_nature(other._nature),
+ _mesh(0),_type(0)
{
if(other._mesh)
{
_mesh=other._mesh;
_mesh->incrRef();
}
+ if(deepCopy)
+ _type=other._type->clone();
+ else
+ _type=other._type;
}
/*!
std::size_t getHeapMemorySize() const;
protected:
MEDCouplingField(TypeOfField type);
- MEDCouplingField(const MEDCouplingField& other);
+ MEDCouplingField(const MEDCouplingField& other, bool deepCopy=true);
MEDCouplingField(MEDCouplingFieldDiscretization *type, NatureOfField nature=NoNature);
virtual ~MEDCouplingField();
protected:
}
}
-TypeOfField MEDCouplingFieldDiscretization::getTypeOfFieldFromStringRepr(const char *repr) throw(INTERP_KERNEL::Exception)
+TypeOfField MEDCouplingFieldDiscretization::GetTypeOfFieldFromStringRepr(const char *repr) throw(INTERP_KERNEL::Exception)
{
std::string reprCpp(repr);
if(reprCpp==MEDCouplingFieldDiscretizationP0::REPR)
return ret;
}
-int MEDCouplingFieldDiscretizationP0::getNumberOfTuples(const MEDCouplingMesh *mesh) const
+int MEDCouplingFieldDiscretizationP0::getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception)
{
return mesh->getNumberOfCells();
}
return ret;
}
-int MEDCouplingFieldDiscretizationOnNodes::getNumberOfTuples(const MEDCouplingMesh *mesh) const
+int MEDCouplingFieldDiscretizationOnNodes::getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception)
{
return mesh->getNumberOfNodes();
}
return REPR;
}
-int MEDCouplingFieldDiscretizationGauss::getNumberOfTuples(const MEDCouplingMesh *) const
+int MEDCouplingFieldDiscretizationGauss::getNumberOfTuples(const MEDCouplingMesh *) const throw(INTERP_KERNEL::Exception)
{
int ret=0;
+ if (_discr_per_cell == 0)
+ throw INTERP_KERNEL::Exception("Discretization is not initialized!");
const int *dcPtr=_discr_per_cell->getConstPointer();
int nbOfTuples=_discr_per_cell->getNumberOfTuples();
for(const int *w=dcPtr;w!=dcPtr+nbOfTuples;w++)
/*!
* This method makes the assumption that _discr_per_cell is set.
* This method reduces as much as possible number size of _loc.
- * This method is usefull when several set on same cells has been done and that some Gauss Localization are no more used.
+ * This method is useful when several set on same cells has been done and that some Gauss Localization are no more used.
*/
void MEDCouplingFieldDiscretizationGauss::zipGaussLocalizations()
{
}
/*!
- * This method is usefull when 'this' describes a field discretization with several gauss discretization on a \b same cell type.
+ * This method is useful when 'this' describes a field discretization with several gauss discretization on a \b same cell type.
* For example same NORM_TRI3 cells having 6 gauss points and others with 12 gauss points.
* This method returns 2 arrays with same size : the return value and 'locIds' output parameter.
* For a given i into [0,locIds.size) ret[i] represents the set of cell ids of i_th set an locIds[i] represents the set of discretisation of the set.
return ret;
}
-int MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuples(const MEDCouplingMesh *mesh) const
+int MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception)
{
int ret=0;
int nbOfCells=mesh->getNumberOfCells();
throw INTERP_KERNEL::Exception("Not implemented yet !");
}
+/*!
+ * Reimplemented from MEDCouplingFieldDiscretization::integral for performance reason. The default implementation is valid too for GAUSS_NE spatial discretization.
+ */
void MEDCouplingFieldDiscretizationGaussNE::integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception)
{
if(!mesh || !arr)
int nbOfCompo=arr->getNumberOfComponents();
std::fill(res,res+nbOfCompo,0.);
//
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> vol=getMeasureField(mesh,isWAbs);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> vol=mesh->getMeasureField(isWAbs);
std::set<INTERP_KERNEL::NormalizedCellType> types=mesh->getAllGeoTypes();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nbOfNodesPerCell=mesh->computeNbOfNodesPerCell();
nbOfNodesPerCell->computeOffsets2();
{
if(!mesh)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::getMeasureField : mesh instance specified is NULL !");
- throw INTERP_KERNEL::Exception("Not implemented yet !");
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> vol=mesh->getMeasureField(isAbs);
+ const double *volPtr=vol->getArray()->begin();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_GAUSS_NE);
+ ret->setMesh(mesh);
+ //
+ std::set<INTERP_KERNEL::NormalizedCellType> types=mesh->getAllGeoTypes();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nbOfNodesPerCell=mesh->computeNbOfNodesPerCell();
+ int nbTuples=nbOfNodesPerCell->accumulate(0);
+ nbOfNodesPerCell->computeOffsets2();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::New(); arr->alloc(nbTuples,1);
+ ret->setArray(arr);
+ double *arrPtr=arr->getPointer();
+ for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=types.begin();it!=types.end();it++)
+ {
+ std::size_t wArrSz=-1;
+ const double *wArr=GetWeightArrayFromGeometricType(*it,wArrSz);
+ INTERP_KERNEL::AutoPtr<double> wArr2=new double[wArrSz];
+ double sum=std::accumulate(wArr,wArr+wArrSz,0.);
+ std::transform(wArr,wArr+wArrSz,(double *)wArr2,std::bind2nd(std::multiplies<double>(),1./sum));
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=mesh->giveCellsWithType(*it);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids2=ids->buildExplicitArrByRanges(nbOfNodesPerCell);
+ const int *ptIds2=ids2->begin(),*ptIds=ids->begin();
+ int nbOfCellsWithCurGeoType=ids->getNumberOfTuples();
+ for(int i=0;i<nbOfCellsWithCurGeoType;i++,ptIds++)
+ for(std::size_t j=0;j<wArrSz;j++,ptIds2++)
+ arrPtr[*ptIds2]=wArr2[j]*volPtr[*ptIds];
+ }
+ ret->synchronizeTimeWithSupport();
+ return ret.retn();
}
void MEDCouplingFieldDiscretizationGaussNE::getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const
void setPrecision(double val) { _precision=val; }
void updateTime() const;
std::size_t getHeapMemorySize() const;
- static TypeOfField getTypeOfFieldFromStringRepr(const char *repr) throw(INTERP_KERNEL::Exception);
+ static TypeOfField GetTypeOfFieldFromStringRepr(const char *repr) throw(INTERP_KERNEL::Exception);
virtual TypeOfField getEnum() const = 0;
virtual bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
virtual bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const = 0;
virtual MEDCouplingFieldDiscretization *clonePart(const int *startCellIds, const int *endCellIds) const;
virtual std::string getStringRepr() const = 0;
virtual const char *getRepr() const = 0;
- virtual int getNumberOfTuples(const MEDCouplingMesh *mesh) const = 0;
+ virtual int getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception) = 0;
virtual int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const = 0;
virtual DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const = 0;
virtual void normL1(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception);
std::string getStringRepr() const;
const char *getRepr() const;
bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
- int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
+ int getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception);
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationOnNodes : public MEDCouplingFieldDiscretization
{
public:
- int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
+ int getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception);
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
std::string getStringRepr() const;
const char *getRepr() const;
std::size_t getHeapMemorySize() const;
- int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
+ int getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception);
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
std::string getStringRepr() const;
const char *getRepr() const;
bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
- int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
+ int getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception);
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
#include "MEDCouplingNatureOfField.hxx"
+#include "InterpKernelAutoPtr.hxx"
+
#include <sstream>
#include <limits>
#include <algorithm>
* \return a newly allocated field the caller should deal with.
*/
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::New(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td)
{
return new MEDCouplingFieldDouble(ft,td);
}
{
}
-MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td):MEDCouplingField(*ft),
+MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td):MEDCouplingField(ft),
_time_discr(MEDCouplingTimeDiscretization::New(td))
{
}
-MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCopy):MEDCouplingField(other),
+MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCopy):MEDCouplingField(other,deepCopy),
_time_discr(other._time_discr->performCpy(deepCopy))
{
}
* \a this is expected to be a field with exactly \b one component. If not an exception will be thrown.
* To getAverageValue on vector field applyFunc is needed before. This method looks only \b default array \b and \b only \b default.
* If default array does not exist, an exception will be thrown.
+ *
+ * \param [out] res the location where the result will be stored. \a res is expected to be a location with \c this->getNumberOfComponents() places available.
+ * \param [in] isWAbs specifies if abs is applied on measure on underlying mesh before performing computation. For a user already sure that all cells of its underlying mesh
+ * are all well oriented this parameter can be set to false to be 'faster'. By default this parameter is true.
*/
-double MEDCouplingFieldDouble::getWeightedAverageValue() const throw(INTERP_KERNEL::Exception)
+void MEDCouplingFieldDouble::getWeightedAverageValue(double *res, bool isWAbs) const throw(INTERP_KERNEL::Exception)
{
if(getArray()==0)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getWeightedAverageValue : no default array defined !");
- MEDCouplingFieldDouble *w=buildMeasureField(true);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> w=buildMeasureField(isWAbs);
double deno=w->getArray()->accumulate(0);
- w->getArray()->multiplyEqual(getArray());
- double res=w->getArray()->accumulate(0);
- w->decrRef();
- return res/deno;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=getArray()->deepCpy();
+ arr->multiplyEqual(w->getArray());
+ std::transform(arr->begin(),arr->end(),arr->getPointer(),std::bind2nd(std::multiplies<double>(),1./deno));
+ arr->accumulate(res);
+}
+
+/*!
+ * This method returns the average value in \a this weighted by ParaMEDMEM::MEDCouplingField::buildMeasureField.
+ * \a this is expected to be a field with exactly \b one component. If not an exception will be thrown.
+ * To getAverageValue on vector field applyFunc is needed before. This method looks only \b default array \b and \b only \b default.
+ * If default array does not exist, an exception will be thrown.
+ *
+ * \param [in] compId The component id that should be in [0, \c this->getNumberOfComponents() ). If not an INTERP_KERNEL::Exception will be thrown.
+ * \param [in] isWAbs specifies if abs is applied on measure on underlying mesh before performing computation. For a user already sure that all cells of its underlying mesh
+ * are all well oriented this parameter can be set to false to be 'faster'. By default this parameter is true in C++ not in python (overloading confusion).
+ */
+double MEDCouplingFieldDouble::getWeightedAverageValue(int compId, bool isWAbs) const throw(INTERP_KERNEL::Exception)
+{
+ int nbComps=getArray()->getNumberOfComponents();
+ if(compId<0 || compId>=nbComps)
+ {
+ std::ostringstream oss; oss << "MEDCouplingFieldDouble::getWeightedAverageValue : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ INTERP_KERNEL::AutoPtr<double> res=new double[nbComps];
+ getWeightedAverageValue(res,isWAbs);
+ return res[compId];
}
/*!
if(!_mesh)
throw INTERP_KERNEL::Exception("No mesh underlying this field to perform normL1");
int nbComps=getArray()->getNumberOfComponents();
- if(compId>=nbComps)
- throw INTERP_KERNEL::Exception("Invalid compId specified : No such nb of components !");
- double *res=new double[nbComps];
- try
- {
- _type->normL1(_mesh,getArray(),res);
- }
- catch(INTERP_KERNEL::Exception& e)
+ if(compId<0 || compId>=nbComps)
{
- delete [] res;
- throw e;
+ std::ostringstream oss; oss << "MEDCouplingFieldDouble::normL1 : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- double ret=res[compId];
- delete [] res;
- return ret;
+ INTERP_KERNEL::AutoPtr<double> res=new double[nbComps];
+ _type->normL1(_mesh,getArray(),res);
+ return res[compId];
}
/*!
if(!_mesh)
throw INTERP_KERNEL::Exception("No mesh underlying this field to perform normL2");
int nbComps=getArray()->getNumberOfComponents();
- if(compId>=nbComps)
- throw INTERP_KERNEL::Exception("Invalid compId specified : No such nb of components !");
- double *res=new double[nbComps];
- try
- {
- _type->normL2(_mesh,getArray(),res);
- }
- catch(INTERP_KERNEL::Exception& e)
+ if(compId<0 || compId>=nbComps)
{
- delete [] res;
- throw e;
+ std::ostringstream oss; oss << "MEDCouplingFieldDouble::normL2 : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- double ret=res[compId];
- delete [] res;
- return ret;
+ INTERP_KERNEL::AutoPtr<double> res=new double[nbComps];
+ _type->normL2(_mesh,getArray(),res);
+ return res[compId];
}
/*!
/*!
* Returns the accumulation (the sum) of comId_th component of each tuples weigthed by the field
* returns by getWeightingField relative of the _type of field of default array.
- * This method is usefull to check the conservativity of interpolation method.
+ * This method is useful to check the conservativity of interpolation method.
*/
double MEDCouplingFieldDouble::integral(int compId, bool isWAbs) const throw(INTERP_KERNEL::Exception)
{
if(!_mesh)
throw INTERP_KERNEL::Exception("No mesh underlying this field to perform integral");
int nbComps=getArray()->getNumberOfComponents();
- if(compId>=nbComps)
- throw INTERP_KERNEL::Exception("Invalid compId specified : No such nb of components !");
- double *res=new double[nbComps];
- try
- {
- _type->integral(_mesh,getArray(),isWAbs,res);
- }
- catch(INTERP_KERNEL::Exception& e)
+ if(compId<0 || compId>=nbComps)
{
- delete [] res;
- throw e;
+ std::ostringstream oss; oss << "MEDCouplingFieldDouble::integral : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- double ret=res[compId];
- delete [] res;
- return ret;
+ INTERP_KERNEL::AutoPtr<double> res=new double[nbComps];
+ _type->integral(_mesh,getArray(),isWAbs,res);
+ return res[compId];
}
/*!
* Returns the accumulation (the sum) of each tuples weigthed by the field
* returns by getWeightingField relative of the _type of field of default array.
- * This method is usefull to check the conservativity of interpolation method.
+ * This method is useful to check the conservativity of interpolation method.
*/
void MEDCouplingFieldDouble::integral(bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception)
{
{
public:
static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME);
- static MEDCouplingFieldDouble *New(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td=ONE_TIME);
+ static MEDCouplingFieldDouble *New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME);
void setTimeUnit(const char *unit);
const char *getTimeUnit() const;
void synchronizeTimeWithSupport() throw(INTERP_KERNEL::Exception);
double getAverageValue() const throw(INTERP_KERNEL::Exception);
double norm2() const throw(INTERP_KERNEL::Exception);
double normMax() const throw(INTERP_KERNEL::Exception);
- double getWeightedAverageValue() const throw(INTERP_KERNEL::Exception);
+ void getWeightedAverageValue(double *res, bool isWAbs=true) const throw(INTERP_KERNEL::Exception);
+ double getWeightedAverageValue(int compId, bool isWAbs=true) const throw(INTERP_KERNEL::Exception);
double normL1(int compId) const throw(INTERP_KERNEL::Exception);
void normL1(double *res) const throw(INTERP_KERNEL::Exception);
double normL2(int compId) const throw(INTERP_KERNEL::Exception);
MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() { return _time_discr; }
private:
MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td);
- MEDCouplingFieldDouble(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td);
+ MEDCouplingFieldDouble(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td);
MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCopy);
MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type);
~MEDCouplingFieldDouble();
using namespace ParaMEDMEM;
-MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldDouble& f) throw(INTERP_KERNEL::Exception)
{
return new MEDCouplingFieldTemplate(f);
}
return new MEDCouplingFieldTemplate(type);
}
-MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception):MEDCouplingField(*f)
+MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldDouble& f) throw(INTERP_KERNEL::Exception):MEDCouplingField(f,false)
{
+ forceTimeOfThis(f);
checkCoherency();
}
class MEDCOUPLING_EXPORT MEDCouplingFieldTemplate : public MEDCouplingField
{
public:
- static MEDCouplingFieldTemplate *New(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldTemplate *New(const MEDCouplingFieldDouble& f) throw(INTERP_KERNEL::Exception);
static MEDCouplingFieldTemplate *New(TypeOfField type);
std::string simpleRepr() const;
std::string advancedRepr() const;
void serialize(DataArrayInt *&dataInt) const;
//
private:
- MEDCouplingFieldTemplate(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldTemplate(const MEDCouplingFieldDouble& f) throw(INTERP_KERNEL::Exception);
MEDCouplingFieldTemplate(TypeOfField type);
};
}
}
}
+template<int SPACEDIM>
+void DataArrayDouble::FindClosestTupleIdAlg(const BBTreePts<SPACEDIM,int>& myTree, double dist, const double *pos, int nbOfTuples, const double *thisPt, int thisNbOfTuples, int *res)
+{
+ double distOpt(dist);
+ const double *p(pos);
+ int *r(res);
+ for(int i=0;i<nbOfTuples;i++,p+=SPACEDIM,r++)
+ {
+ while(true)
+ {
+ int elem=-1;
+ double ret=myTree.getElementsAroundPoint2(p,distOpt,elem);
+ if(ret!=std::numeric_limits<double>::max())
+ {
+ distOpt=std::max(ret,1e-4);
+ *r=elem;
+ break;
+ }
+ else
+ { distOpt=2*distOpt; continue; }
+ }
+ }
+}
+
std::size_t DataArray::getHeapMemorySize() const
{
std::size_t sz1=_name.capacity();
return sz1+sz2+sz3;
}
+/*!
+ * Sets the attribute \a _name of \a this array.
+ * See \ref MEDCouplingArrayBasicsName "DataArrays infos" for more information.
+ * \param [in] name - new array name
+ */
void DataArray::setName(const char *name)
{
_name=name;
}
+/*!
+ * Copies textual data from an \a other DataArray. The copied data are
+ * - the name attribute,
+ * - the information of components.
+ *
+ * For more information on these data see \ref MEDCouplingArrayBasicsName "DataArrays infos".
+ *
+ * \param [in] other - another instance of DataArray to copy the textual data from.
+ * \throw If number of components of \a this array differs from that of the \a other.
+ */
void DataArray::copyStringInfoFrom(const DataArray& other) throw(INTERP_KERNEL::Exception)
{
if(_info_on_compo.size()!=other._info_on_compo.size())
return true;
}
+/*!
+ * Compares textual information of \a this DataArray with that of an \a other one.
+ * The compared data are
+ * - the name attribute,
+ * - the information of components.
+ *
+ * For more information on these data see \ref MEDCouplingArrayBasicsName "DataArrays infos".
+ * \param [in] other - another instance of DataArray to compare the textual data of.
+ * \return bool - \a true if the textual information is same, \a false else.
+ */
bool DataArray::areInfoEquals(const DataArray& other) const
{
std::string tmp;
return ret.str();
}
+/*!
+ * Sets information on all components. To know more on format of this information
+ * see \ref MEDCouplingArrayBasicsCompoName "DataArrays infos".
+ * \param [in] info - a vector of strings.
+ * \throw If size of \a info differs from the number of components of \a this.
+ */
void DataArray::setInfoOnComponents(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()!=(int)info.size())
return ret;
}
+/*!
+ * Returns information on a component specified by an index.
+ * To know more on format of this information
+ * see \ref MEDCouplingArrayBasicsCompoName "DataArrays infos".
+ * \param [in] i - the index (zero based) of the component of interest.
+ * \return std::string - a string containing the information on \a i-th component.
+ * \throw If \a i is not a valid component index.
+ */
std::string DataArray::getInfoOnComponent(int i) const throw(INTERP_KERNEL::Exception)
{
if(i<(int)_info_on_compo.size() && i>=0)
}
/*!
- * In the info part of i_th component this method returns the var part.
- * For example, if getInfoOnComponent(0) return "SIGXY (N/m^2)", getVarOnComponent(0) will return "SIGXY"
+ * Returns the var part of the full information of the \a i-th component.
+ * For example, if \c getInfoOnComponent(0) returns "SIGXY [N/m^2]", then
+ * \c getVarOnComponent(0) returns "SIGXY".
+ * If a unit part of information is not detected by presence of
+ * two square brackets, then the full information is returned.
+ * To read more about the component information format, see
+ * \ref MEDCouplingArrayBasicsCompoName "DataArrays infos".
+ * \param [in] i - the index (zero based) of the component of interest.
+ * \return std::string - a string containing the var information, or the full info.
+ * \throw If \a i is not a valid component index.
*/
std::string DataArray::getVarOnComponent(int i) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * In the info part of i_th component this method returns the var part.
- * For example, if getInfoOnComponent(0) return "SIGXY (N/m^2)", getUnitOnComponent(0) will return "N/m^2"
+ * Returns the unit part of the full information of the \a i-th component.
+ * For example, if \c getInfoOnComponent(0) returns "SIGXY [ N/m^2]", then
+ * \c getUnitOnComponent(0) returns " N/m^2".
+ * If a unit part of information is not detected by presence of
+ * two square brackets, then an empty string is returned.
+ * To read more about the component information format, see
+ * \ref MEDCouplingArrayBasicsCompoName "DataArrays infos".
+ * \param [in] i - the index (zero based) of the component of interest.
+ * \return std::string - a string containing the unit information, if any, or "".
+ * \throw If \a i is not a valid component index.
*/
std::string DataArray::getUnitOnComponent(int i) const throw(INTERP_KERNEL::Exception)
{
}
}
+/*!
+ * Returns the var part of the full component information.
+ * For example, if \a info == "SIGXY [N/m^2]", then this method returns "SIGXY".
+ * If a unit part of information is not detected by presence of
+ * two square brackets, then the whole \a info is returned.
+ * To read more about the component information format, see
+ * \ref MEDCouplingArrayBasicsCompoName "DataArrays infos".
+ * \param [in] info - the full component information.
+ * \return std::string - a string containing only var information, or the \a info.
+ */
std::string DataArray::GetVarNameFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception)
{
std::size_t p1=info.find_last_of('[');
return info.substr(0,p3+1);
}
+/*!
+ * Returns the unit part of the full component information.
+ * For example, if \a info == "SIGXY [ N/m^2]", then this method returns " N/m^2".
+ * If a unit part of information is not detected by presence of
+ * two square brackets, then an empty string is returned.
+ * To read more about the component information format, see
+ * \ref MEDCouplingArrayBasicsCompoName "DataArrays infos".
+ * \param [in] info - the full component information.
+ * \return std::string - a string containing only unit information, if any, or "".
+ */
std::string DataArray::GetUnitFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception)
{
std::size_t p1=info.find_last_of('[');
return info.substr(p1+1,p2-p1-1);
}
+/*!
+ * Sets information on a component specified by an index.
+ * To know more on format of this information
+ * see \ref MEDCouplingArrayBasicsCompoName "DataArrays infos".
+ * \param [in] i - the index (zero based) of the component of interest.
+ * \param [in] info - the string containing the information.
+ * \throw If \a i is not a valid component index.
+ * \warning Don't pass NULL as \a info!
+ */
void DataArray::setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception)
{
if(i<(int)_info_on_compo.size() && i>=0)
return -1;
}
+/*!
+ * Returns a new instance of DataArrayDouble. The caller is to delete this array
+ * using decrRef() as it is no more needed.
+ */
DataArrayDouble *DataArrayDouble::New()
{
return new DataArrayDouble;
}
+/*!
+ * Checks if raw data is allocated. Read more on the raw data
+ * in \ref MEDCouplingArrayBasicsTuplesAndCompo "DataArrays infos" for more information.
+ * \return bool - \a true if the raw data is allocated, \a false else.
+ */
bool DataArrayDouble::isAllocated() const
{
return getConstPointer()!=0;
}
+/*!
+ * Checks if raw data is allocated and throws an exception if it is not the case.
+ * \throw If the raw data is not allocated.
+ */
void DataArrayDouble::checkAllocated() const throw(INTERP_KERNEL::Exception)
{
if(!isAllocated())
}
/*!
- * This method differs from DataArray::setInfoOnComponents in the sense that if 'this->getNumberOfComponents()!=info.size()'
- * and if 'this' is not allocated it will change the number of components of 'this'.
- * If 'this->getNumberOfComponents()==info.size()' the behaviour is the same than DataArray::setInfoOnComponents method.
- * If 'this->getNumberOfComponents()!=info.size()' and the 'this' is already allocated an exception will be thrown.
+ * Sets information on all components. This method can change number of components
+ * at certain conditions; if the conditions are not respected, an exception is thrown.
+ * The number of components can be changed provided that \a this is not allocated.
+ *
+ * To know more on format of the component information see
+ * \ref MEDCouplingArrayBasicsCompoName "DataArrays infos".
+ * \param [in] info - a vector of component infos.
+ * \throw If \a this->getNumberOfComponents() != \a info.size() && \a this->isAllocated()
*/
void DataArrayDouble::setInfoAndChangeNbOfCompo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method returns the only one value in 'this', if and only if number of elements (nb of tuples * nb of components) is equal to 1, and that 'this' is allocated.
- * If one or more conditions is not fulfilled an exception will be thrown.
+ * Returns the only one value in \a this, if and only if number of elements
+ * (nb of tuples * nb of components) is equal to 1, and that \a this is allocated.
+ * \return double - the sole value stored in \a this array.
+ * \throw If at least one of conditions stated above is not fulfilled.
*/
double DataArrayDouble::doubleValue() const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method should be called on an allocated DataArrayDouble instance. If not an exception will be throw !
- * This method checks the number of tupes. If it is equal to 0, it returns true, if not false is returned.
+ * Checks the number of tuples.
+ * \return bool - \a true if getNumberOfTuples() == 0, \a false else.
+ * \throw If \a this is not allocated.
*/
bool DataArrayDouble::empty() const throw(INTERP_KERNEL::Exception)
{
return getNumberOfTuples()==0;
}
+/*!
+ * Returns a full copy of \a this. For more info on copying data arrays see
+ * \ref MEDCouplingArrayBasicsCopyDeep.
+ * \return DataArrayDouble * - a new instance of DataArrayDouble.
+ */
DataArrayDouble *DataArrayDouble::deepCpy() const
{
return new DataArrayDouble(*this);
}
+/*!
+ * Returns either a \a deep or \a shallow copy of this array. For more info see
+ * \ref MEDCouplingArrayBasicsCopyDeep and \ref MEDCouplingArrayBasicsCopyShallow.
+ * \param [in] dCpy - if \a true, a deep copy is returned, else, a shallow one.
+ * \return DataArrayDouble * - either a new instance of DataArrayDouble (if \a dCpy
+ * == \a true) or \a this instance (if \a dCpy == \a false).
+ */
DataArrayDouble *DataArrayDouble::performCpy(bool dCpy) const
{
if(dCpy)
}
}
+/*!
+ * Copies all the data from another DataArrayDouble. For more info see
+ * \ref MEDCouplingArrayBasicsCopyDeepAssign.
+ * \param [in] other - another instance of DataArrayDouble to copy data from.
+ * \throw If the \a other is not allocated.
+ */
void DataArrayDouble::cpyFrom(const DataArrayDouble& other) throw(INTERP_KERNEL::Exception)
{
other.checkAllocated();
copyStringInfoFrom(other);
}
+/*!
+ * This method reserve nbOfElems elements in memory ( nbOfElems*8 bytes ) \b without impacting the number of tuples in \a this.
+ * If \a this has already been allocated, this method checks that \a this has only one component. If not an INTERP_KERNEL::Exception will be thrown.
+ * If \a this has not already been allocated, number of components is set to one.
+ * This method allows to reduce number of reallocations on invokation of DataArrayDouble::pushBackSilent and DataArrayDouble::pushBackValsSilent on \a this.
+ *
+ * \sa DataArrayDouble::pack, DataArrayDouble::pushBackSilent, DataArrayDouble::pushBackValsSilent
+ */
void DataArrayDouble::reserve(int nbOfElems) throw(INTERP_KERNEL::Exception)
{
int nbCompo=getNumberOfComponents();
throw INTERP_KERNEL::Exception("DataArrayDouble::reserve : not available for DataArrayDouble with number of components different than 1 !");
}
+/*!
+ * This method adds at the end of \a this the single value \a val. This method do \b not update its time label to avoid useless incrementation
+ * of counter. So the caller is expected to call TimeLabel::declareAsNew on \a this at the end of the push session.
+ *
+ * \param [in] val the value to be added in \a this
+ * \throw If \a this has already been allocated with number of components different from one.
+ * \sa DataArrayDouble::pushBackValsSilent
+ */
void DataArrayDouble::pushBackSilent(double val) throw(INTERP_KERNEL::Exception)
{
int nbCompo=getNumberOfComponents();
throw INTERP_KERNEL::Exception("DataArrayDouble::pushBackSilent : not available for DataArrayDouble with number of components different than 1 !");
}
+/*!
+ * This method adds at the end of \a this a serie of values [\c valsBg,\c valsEnd). This method do \b not update its time label to avoid useless incrementation
+ * of counter. So the caller is expected to call TimeLabel::declareAsNew on \a this at the end of the push session.
+ *
+ * \param [in] valsBg - an array of values to push at the end of \this.
+ * \param [in] valsEnd - specifies the end of the array \a valsBg, so that
+ * the last value of \a valsBg is \a valsEnd[ -1 ].
+ * \throw If \a this has already been allocated with number of components different from one.
+ * \sa DataArrayDouble::pushBackSilent
+ */
void DataArrayDouble::pushBackValsSilent(const double *valsBg, const double *valsEnd) throw(INTERP_KERNEL::Exception)
{
int nbCompo=getNumberOfComponents();
throw INTERP_KERNEL::Exception("DataArrayDouble::pushBackValsSilent : not available for DataArrayDouble with number of components different than 1 !");
}
+/*!
+ * This method returns silently ( without updating time label in \a this ) the last value, if any and suppress it.
+ * \throw If \a this is already empty.
+ * \throw If \a this has number of components different from one.
+ */
double DataArrayDouble::popBackSilent() throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()==1)
throw INTERP_KERNEL::Exception("DataArrayDouble::popBackSilent : not available for DataArrayDouble with number of components different than 1 !");
}
+/*!
+ * This method \b do \b not modify content of \a this. It only modify its memory footprint if the allocated memory is to high regarding real data to store.
+ *
+ * \sa DataArrayDouble::getHeapMemorySize, DataArrayDouble::reserve
+ */
void DataArrayDouble::pack() const throw(INTERP_KERNEL::Exception)
{
_mem.pack();
}
+/*!
+ * Allocates the raw data in memory. If exactly same memory as needed already
+ * allocated, it is not re-allocated.
+ * \param [in] nbOfTuple - number of tuples of data to allocate.
+ * \param [in] nbOfCompo - number of components of data to allocate.
+ * \throw If \a nbOfTuple < 0 or \a nbOfCompo < 0.
+ */
void DataArrayDouble::allocIfNecessary(int nbOfTuple, int nbOfCompo)
{
if(isAllocated())
alloc(nbOfTuple,nbOfCompo);
}
+/*!
+ * Allocates the raw data in memory. If the memory was already allocated, then it is
+ * freed and re-allocated. See an example of this method use
+ * \ref MEDCouplingArraySteps1WC "here".
+ * \param [in] nbOfTuple - number of tuples of data to allocate.
+ * \param [in] nbOfCompo - number of components of data to allocate.
+ * \throw If \a nbOfTuple < 0 or \a nbOfCompo < 0.
+ */
void DataArrayDouble::alloc(int nbOfTuple, int nbOfCompo) throw(INTERP_KERNEL::Exception)
{
if(nbOfTuple<0 || nbOfCompo<0)
declareAsNew();
}
+/*!
+ * Assign zero to all values in \a this array. To know more on filling arrays see
+ * \ref MEDCouplingArrayFill.
+ * \throw If \a this is not allocated.
+ */
void DataArrayDouble::fillWithZero() throw(INTERP_KERNEL::Exception)
{
checkAllocated();
declareAsNew();
}
+/*!
+ * Assign \a val to all values in \a this array. To know more on filling arrays see
+ * \ref MEDCouplingArrayFill.
+ * \param [in] val - the value to fill with.
+ * \throw If \a this is not allocated.
+ */
void DataArrayDouble::fillWithValue(double val) throw(INTERP_KERNEL::Exception)
{
checkAllocated();
declareAsNew();
}
+/*!
+ * Set all values in \a this array so that the i-th element equals to \a init + i
+ * (i starts from zero). To know more on filling arrays see \ref MEDCouplingArrayFill.
+ * \param [in] init - value to assign to the first element of array.
+ * \throw If \a this->getNumberOfComponents() != 1
+ * \throw If \a this is not allocated.
+ */
void DataArrayDouble::iota(double init) throw(INTERP_KERNEL::Exception)
{
checkAllocated();
declareAsNew();
}
+/*!
+ * Checks if all values in \a this array are equal to \a val at precision \a eps.
+ * \param [in] val - value to check equality of array values to.
+ * \param [in] eps - precision to check the equality.
+ * \return bool - \a true if all values are in range (_val_ - _eps_; _val_ + _eps_),
+ * \a false else.
+ * \throw If \a this->getNumberOfComponents() != 1
+ * \throw If \a this is not allocated.
+ */
bool DataArrayDouble::isUniform(double val, double eps) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return true;
}
+/*!
+ * Sorts values of the array.
+ * \param [in] asc - \a true means ascending order, \a false, descending.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ */
void DataArrayDouble::sort(bool asc) throw(INTERP_KERNEL::Exception)
{
checkAllocated();
_mem.sort(asc);
}
+/*!
+ * Reverse the array values.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If \a this is not allocated.
+ */
void DataArrayDouble::reverse() throw(INTERP_KERNEL::Exception)
{
checkAllocated();
}
/*!
- * This method check that (Maths) array consistently INCREASING or DECREASING in value,
- * with at least absolute difference value of |eps| at each step.
- * if not an exception will be thrown.
+ * Checks that \a this array is consistently **increasing** or **decreasing** in value,
+ * with at least absolute difference value of |\a eps| at each step.
+ * If not an exception is thrown.
+ * \param [in] increasing - if \a true, the array values should be increasing.
+ * \param [in] eps - minimal absolute difference between the neighbor values at which
+ * the values are considered different.
+ * \throw If sequence of values is not strictly monotonic in agreement with \a
+ * increasing arg.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If \a this is not allocated.
*/
- void DataArrayDouble::checkMonotonic(bool increasing, double eps) const throw(INTERP_KERNEL::Exception)
+void DataArrayDouble::checkMonotonic(bool increasing, double eps) const throw(INTERP_KERNEL::Exception)
{
if(!isMonotonic(increasing,eps))
{
}
/*!
- * This method check that (Maths) array consistently INCREASING or DECREASING in value,
- * with at least absolute difference value of |eps| at each step.
+ * Checks that \a this array is consistently **increasing** or **decreasing** in value,
+ * with at least absolute difference value of |\a eps| at each step.
+ * \param [in] increasing - if \a true, array values should be increasing.
+ * \param [in] eps - minimal absolute difference between the neighbor values at which
+ * the values are considered different.
+ * \return bool - \a true if values change in accordance with \a increasing arg.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If \a this is not allocated.
*/
bool DataArrayDouble::isMonotonic(bool increasing, double eps) const throw(INTERP_KERNEL::Exception)
{
}
}
+/*!
+ * Returns a textual and human readable representation of \a this instance of
+ * DataArrayDouble. This text is shown when a DataArrayDouble is printed in Python.
+ * \return std::string - text describing \a this DataArrayDouble.
+ */
std::string DataArrayDouble::repr() const
{
std::ostringstream ret;
return _mem.isEqual(other._mem,prec,reason);
}
+/*!
+ * Checks if \a this and another DataArrayDouble are fully equal. For more info see
+ * \ref MEDCouplingArrayBasicsCompare.
+ * \param [in] other - an instance of DataArrayDouble to compare with \a this one.
+ * \param [in] prec - precision value to compare numeric data of the arrays.
+ * \return bool - \a true if the two arrays are equal, \a false else.
+ */
bool DataArrayDouble::isEqual(const DataArrayDouble& other, double prec) const
{
std::string tmp;
return isEqualIfNotWhy(other,prec,tmp);
}
+/*!
+ * Checks if values of \a this and another DataArrayDouble are equal. For more info see
+ * \ref MEDCouplingArrayBasicsCompare.
+ * \param [in] other - an instance of DataArrayDouble to compare with \a this one.
+ * \param [in] prec - precision value to compare numeric data of the arrays.
+ * \return bool - \a true if the values of two arrays are equal, \a false else.
+ */
bool DataArrayDouble::isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const
{
std::string tmp;
return _mem.isEqual(other._mem,prec,tmp);
}
+/*!
+ * Changes number of tuples in the array. If the new number of tuples is smaller
+ * than the current number the array is truncated, otherwise the array is extended.
+ * \param [in] nbOfTuples - new number of tuples.
+ * \throw If \a this is not allocated.
+ */
void DataArrayDouble::reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception)
{
checkAllocated();
declareAsNew();
}
+/*!
+ * Creates a new DataArrayInt and assigns all (textual and numerical) data of \a this
+ * array to the new one.
+ * \return DataArrayInt * - the new instance of DataArrayInt.
+ */
DataArrayInt *DataArrayDouble::convertToIntArr() const
{
DataArrayInt *ret=DataArrayInt::New();
return ret;
}
+/*!
+ * Returns a new DataArrayDouble holding the same values as \a this array but differently
+ * arranged in memory. If \a this array holds 2 components of 3 values:
+ * \f$ x_0,x_1,x_2,y_0,y_1,y_2 \f$, then the result array holds these values arranged
+ * as follows: \f$ x_0,y_0,x_1,y_1,x_2,y_2 \f$.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
+ * \warning Do not confuse this method with transpose()!
+ */
DataArrayDouble *DataArrayDouble::fromNoInterlace() const throw(INTERP_KERNEL::Exception)
{
if(_mem.isNull())
return ret;
}
+/*!
+ * Returns a new DataArrayDouble holding the same values as \a this array but differently
+ * arranged in memory. If \a this array holds 2 components of 3 values:
+ * \f$ x_0,y_0,x_1,y_1,x_2,y_2 \f$, then the result array holds these values arranged
+ * as follows: \f$ x_0,x_1,x_2,y_0,y_1,y_2 \f$.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
+ * \warning Do not confuse this method with transpose()!
+ */
DataArrayDouble *DataArrayDouble::toNoInterlace() const throw(INTERP_KERNEL::Exception)
{
if(_mem.isNull())
}
/*!
- * This method does \b not change the number of tuples after this call.
- * Only a permutation is done. If a permutation reduction is needed substr, or selectByTupleId should be used.
+ * Permutes values of \a this array as required by \a old2New array. The values are
+ * permuted so that \c new[ \a old2New[ i ]] = \c old[ i ]. Number of tuples remains
+ * the same as in \this one.
+ * If a permutation reduction is needed, substr() or selectByTupleId() should be used.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] old2New - C array of length equal to \a this->getNumberOfTuples()
+ * giving a new position for i-th old value.
*/
void DataArrayDouble::renumberInPlace(const int *old2New)
{
}
/*!
- * This method does \b not change the number of tuples after this call.
- * Only a permutation is done.
+ * Permutes values of \a this array as required by \a new2Old array. The values are
+ * permuted so that \c new[ i ] = \c old[ \a new2Old[ i ]]. Number of tuples remains
+ * the same as in \this one.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] new2Old - C array of length equal to \a this->getNumberOfTuples()
+ * giving a previous position of i-th new value.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
+ * is to delete using decrRef() as it is no more needed.
*/
void DataArrayDouble::renumberInPlaceR(const int *new2Old)
{
}
/*!
- * This method does \b not change the number of tuples after this call.
- * Only a permutation is done. If a permutation reduction is needed renumberAndReduce.
+ * Returns a copy of \a this array with values permuted as required by \a old2New array.
+ * The values are permuted so that \c new[ \a old2New[ i ]] = \c old[ i ].
+ * Number of tuples in the result array remains the same as in \this one.
+ * If a permutation reduction is needed, renumberAndReduce() should be used.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] old2New - C array of length equal to \a this->getNumberOfTuples()
+ * giving a new position for i-th old value.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
*/
DataArrayDouble *DataArrayDouble::renumber(const int *old2New) const
{
}
/*!
- * This method does \b not change the number of tuples after this call.
- * Only a permutation is done. If a permutation reduction is needed substr, or selectByTupleId should be used.
+ * Returns a copy of \a this array with values permuted as required by \a new2Old array.
+ * The values are permuted so that \c new[ i ] = \c old[ \a new2Old[ i ]]. Number of
+ * tuples in the result array remains the same as in \this one.
+ * If a permutation reduction is needed, substr() or selectByTupleId() should be used.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] new2Old - C array of length equal to \a this->getNumberOfTuples()
+ * giving a previous position of i-th new value.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
+ * is to delete using decrRef() as it is no more needed.
*/
DataArrayDouble *DataArrayDouble::renumberR(const int *new2Old) const
{
}
/*!
- * Idem DataArrayDouble::renumber method except that the number of tuples is reduced.
- * That is to say that it is expected that newNbOfTuple<this->getNumberOfTuples().
- * ['old2New','old2New'+getNumberOfTuples()) defines a range containing old to new array. For every negative value in ['old2NewBg','old2New'+getNumberOfTuples()) the corresponding tuple is
- * omitted.
+ * Returns a shorten and permuted copy of \a this array. The new DataArrayDouble is
+ * of size \a newNbOfTuple and it's values are permuted as required by \a old2New array.
+ * The values are permuted so that \c new[ \a old2New[ i ]] = \c old[ i ] for all
+ * \a old2New[ i ] >= 0. In other words every i-th tuple in \a this array, for which
+ * \a old2New[ i ] is negative, is missing from the result array.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] old2New - C array of length equal to \a this->getNumberOfTuples()
+ * giving a new position for i-th old tuple and giving negative position for
+ * for i-th old tuple that should be omitted.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
+ * is to delete using decrRef() as it is no more needed.
*/
DataArrayDouble *DataArrayDouble::renumberAndReduce(const int *old2New, int newNbOfTuple) const
{
}
/*!
- * This method is a generalization of DataArrayDouble::substr method because a not contigous range can be specified here.
- * This method is equivalent to DataArrayDouble::renumberAndReduce except that convention in input is new2old and \b not old2new.
+ * Returns a shorten and permuted copy of \a this array. The new DataArrayDouble is
+ * of size \a new2OldEnd - \a new2OldBg and it's values are permuted as required by
+ * \a new2OldBg array.
+ * The values are permuted so that \c new[ i ] = \c old[ \a new2OldBg[ i ]].
+ * This method is equivalent to renumberAndReduce() except that convention in input is
+ * \c new2old and \b not \c old2new.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] new2OldBg - pointer to the beginning of a permutation array that gives a
+ * tuple index in \a this array to fill the i-th tuple in the new array.
+ * \param [in] new2OldEnd - specifies the end of the permutation array that starts at
+ * \a new2OldBg, so that pointer to a tuple index (\a pi) varies as this:
+ * \a new2OldBg <= \a pi < \a new2OldEnd.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
+ * is to delete using decrRef() as it is no more needed.
*/
DataArrayDouble *DataArrayDouble::selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const
{
}
/*!
- * This method is equivalent to DataArrayDouble::selectByTupleId except that an analyze to the content of input range to check that it will not lead to memory corruption !
+ * Returns a shorten and permuted copy of \a this array. The new DataArrayDouble is
+ * of size \a new2OldEnd - \a new2OldBg and it's values are permuted as required by
+ * \a new2OldBg array.
+ * The values are permuted so that \c new[ i ] = \c old[ \a new2OldBg[ i ]].
+ * This method is equivalent to renumberAndReduce() except that convention in input is
+ * \c new2old and \b not \c old2new.
+ * This method is equivalent to selectByTupleId() except that it prevents coping data
+ * from behind the end of \a this array.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] new2OldBg - pointer to the beginning of a permutation array that gives a
+ * tuple index in \a this array to fill the i-th tuple in the new array.
+ * \param [in] new2OldEnd - specifies the end of the permutation array that starts at
+ * \a new2OldBg, so that pointer to a tuple index (\a pi) varies as this:
+ * \a new2OldBg <= \a pi < \a new2OldEnd.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a new2OldEnd - \a new2OldBg > \a this->getNumberOfTuples().
*/
DataArrayDouble *DataArrayDouble::selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * Idem than DataArrayInt::selectByTupleIdSafe except that the input array is not constructed explicitely.
- * The convention is as python one. ['bg','end2') with steps of 'step'.
- * Returns a newly created array.
- * This method is a generalization of DataArrayDouble::substr.
- *
- * \sa DataArrayDouble::substr
+ * Returns a shorten copy of \a this array. The new DataArrayDouble contains every
+ * (\a bg + \c i * \a step)-th tuple of \a this array located before the \a end2-th
+ * tuple. Indices of the selected tuples are the same as ones returned by the Python
+ * command \c range( \a bg, \a end2, \a step ).
+ * This method is equivalent to selectByTupleIdSafe() except that the input array is
+ * not constructed explicitly.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] bg - index of the first tuple to copy from \a this array.
+ * \param [in] end2 - index of the tuple before which the tuples to copy are located.
+ * \param [in] step - index increment to get index of the next tuple to copy.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If (\a end2 < \a bg) or (\a step <= 0).
+ * \sa DataArrayDouble::substr.
*/
DataArrayDouble *DataArrayDouble::selectByTupleId2(int bg, int end2, int step) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method returns a newly allocated array that is the concatenation of all tuples ranges in param 'ranges'.
- * Each pair in input 'ranges' is in [begin,end) format. If there is a range in 'ranges' so that end is before begin an exception
- * will be thrown. If there is a range in 'ranges' so that end is greater than number of tuples of 'this', an exception will be thrown too.
+ * Returns a shorten copy of \a this array. The new DataArrayDouble contains ranges
+ * of tuples specified by \a ranges parameter.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] ranges - std::vector of std::pair's each of which defines a range
+ * of tuples in [\c begin,\c end) format.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a end < \a begin.
+ * \throw If \a end > \a this->getNumberOfTuples().
+ * \throw If \a this is not allocated.
*/
DataArrayDouble *DataArrayDouble::selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This methods has a similar behaviour than std::string::substr. This method returns a newly created DataArrayInt that is part of this with same number of components.
- * The intervall is specified by [tupleIdBg,tupleIdEnd) except if tupleIdEnd ==-1 in this case the [tupleIdBg,this->end()) will be kept.
- * This method check that interval is valid regarding this, if not an exception will be thrown.
- * This method is a specialization of method DataArrayDouble::selectByTupleId2.
- *
- * \sa DataArrayDouble::selectByTupleId2
+ * Returns a shorten copy of \a this array. The new DataArrayDouble contains all
+ * tuples starting from the \a tupleIdBg-th tuple and including all tuples located before
+ * the \a tupleIdEnd-th one. This methods has a similar behavior as std::string::substr().
+ * This method is a specialization of selectByTupleId2().
+ * \param [in] tupleIdBg - index of the first tuple to copy from \a this array.
+ * \param [in] tupleIdEnd - index of the tuple before which the tuples to copy are located.
+ * If \a tupleIdEnd == -1, all the tuples till the end of \a this array are copied.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a tupleIdBg < 0.
+ * \throw If \a tupleIdBg > \a this->getNumberOfTuples().
+ \throw If \a tupleIdEnd != -1 && \a tupleIdEnd < \a this->getNumberOfTuples().
+ * \sa DataArrayDouble::selectByTupleId2
*/
DataArrayDouble *DataArrayDouble::substr(int tupleIdBg, int tupleIdEnd) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method builds a new instance of DataArrayDouble (to deal with) that is reduction or an extension of 'this'.
- * if 'newNbOfComp' < this->getNumberOfComponents() a reduction is done and for each tuple 'newNbOfComp' first components are kept.
- * If 'newNbOfComp' > this->getNumberOfComponents() an extension is done, and for each components i such that i > getNumberOfComponents() 'dftValue' parameter is taken.
+ * Returns a shorten or extended copy of \a this array. If \a newNbOfComp is less
+ * than \a this->getNumberOfComponents() then the result array is shorten as each tuple
+ * is truncated to have \a newNbOfComp components, keeping first components. If \a
+ * newNbOfComp is more than \a this->getNumberOfComponents() then the result array is
+ * expanded as each tuple is populated with \a dftValue to have \a newNbOfComp
+ * components.
+ * \param [in] newNbOfComp - number of components for the new array to have.
+ * \param [in] dftValue - value assigned to new values added to the new array.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
*/
DataArrayDouble *DataArrayDouble::changeNbOfComponents(int newNbOfComp, double dftValue) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * Contrary to DataArrayDouble::changeNbOfComponents method this method is \b not const. The content
- * This method \b do \b not change the content of data but changes the splitting of this data seen by the caller.
- * This method makes the assumption that 'this' is already allocated. If not an exception will be thrown.
- * This method checks that getNbOfElems()%newNbOfCompo==0. If not an exception will be throw !
- * This method erases all components info set before call !
+ * Changes the number of components within \a this array so that its raw data **does
+ * not** change, instead splitting this data into tuples changes.
+ * \param [in] newNbOfComp - number of components for \a this array to have.
+ * \throw If \a this is not allocated
+ * \throw If getNbOfElems() % \a newNbOfCompo != 0.
+ * \warning This method erases all (name and unit) component info set before!
*/
void DataArrayDouble::rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method makes the assumption that \b this is allocated. If not an INTERP_KERNEL::Exception will be raised.
- * This method does not echange the values stored in \b this. Simply, the number of components before the call becomes the number of
- * tuples and inversely the number of tuples becomes the number of components. \b WARNING the info on components can be alterated by this method.
+ * Changes the number of components within \a this array to be equal to its number
+ * of tuples, and inversely its number of tuples to become equal to its number of
+ * components. So that its raw data **does not** change, instead splitting this
+ * data into tuples changes.
+ * \throw If \a this is not allocated.
+ * \warning This method erases all (name and unit) component info set before!
+ * \warning Do not confuse this method with fromNoInterlace() and toNoInterlace()!
+ * \sa rearrange()
*/
void DataArrayDouble::transpose() throw(INTERP_KERNEL::Exception)
{
rearrange(nbOfTuples);
}
+/*!
+ * Returns a copy of \a this array composed of selected components.
+ * The new DataArrayDouble has the same number of tuples but includes components
+ * specified by \a compoIds parameter. So that getNbOfElems() of the result array
+ * can be either less, same or more than \a this->getNbOfElems().
+ * \param [in] compoIds - sequence of zero based indices of components to include
+ * into the new array.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
+ * \throw If a component index (\a i) is not valid:
+ * \a i < 0 || \a i >= \a this->getNumberOfComponents().
+ *
+ * \ref cpp_mcdataarraydouble_keepselectedcomponents "Here is a Python example".
+ */
DataArrayDouble *DataArrayDouble::keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
}
/*!
- * This method melds the components of 'this' with components of 'other'.
- * After this call in case of success, 'this' will contain a number of components equal to the sum of 'this'
- * before the call and the number of components of 'other'.
- * This method expects that 'this' and 'other' have exactly the same number of tuples. If not an exception is thrown.
+ * Appends components of another array to components of \a this one, tuple by tuple.
+ * So that the number of tuples of \a this array remains the same and the number of
+ * components increases.
+ * \param [in] other - the DataArrayDouble to append to \a this one.
+ * \throw If \a this is not allocated.
+ * \throw If \a this and \a other arrays have different number of tuples.
+ *
+ * \ref cpp_mcdataarraydouble_meldwith "Here is a C++ example".
+ *
+ * \ref py_mcdataarraydouble_meldwith "Here is a Python example".
*/
void DataArrayDouble::meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This methods searches for each tuple if there are any tuples in 'this' that are less far than 'prec' from n1. if any, these tuples are stored in out params
- * comm and commIndex. The distance is computed using norm2. This method expects that 'this' is allocated and that the number of components is in [1,2,3].
- * If not an exception will be thrown.
- * This method is typically used by MEDCouplingPointSet::findCommonNodes and MEDCouplingUMesh::mergeNodes.
- * In case of success, commIndex->getNumberOfTuples()-1 gives the number of tuples groupes that are within distance 'prec'.
- * comm->getNumberOfTuples()==commIndex->back()
- * The returned pair of DataArrayInt instances ('comm','commIndex') is called Surjectived Format 2 \sa DataArrayInt::BuildNew2OldArrayFromSurjectiveFormat2.
- * This format is more compact in surjective format because only all tuple ids not in 'comm' are remain unchanged.
- *
- * @param prec is an absolute precision.
- * @param limitTupleId is the limit tuple id. All tuples which id is strictly lower than 'limiTupleId' will not be merged each other.
- * @param comm out parameter (not inout). Number of components is equal to 1.
- * @param commIndex out parameter (not inout). Number of components is equal to 1.
+ * Searches for tuples coincident within \a prec tolerance. Each tuple is considered
+ * as coordinates of a point in getNumberOfComponents()-dimensional space. The
+ * distance is computed using norm2.
+ *
+ * Indices of coincident tuples are stored in output arrays.
+ * A pair of arrays (\a comm, \a commIndex) is called "Surjective Format 2".
+ *
+ * This method is typically used by MEDCouplingPointSet::findCommonNodes() and
+ * MEDCouplingUMesh::mergeNodes().
+ * \param [in] prec - minimal absolute distance between two tuples at which they are
+ * considered not coincident.
+ * \param [in] limitTupleId - limit tuple id. Tuples with id strictly lower than \a
+ * limitTupleId are not considered.
+ * \param [out] comm - the array holding ids (== indices) of coincident tuples.
+ * \a comm->getNumberOfComponents() == 1.
+ * \a comm->getNumberOfTuples() == \a commIndex->back().
+ * \param [out] commIndex - the array dividing all indices stored in \a comm into
+ * groups of (indices of) coincident tuples. Its every value is a tuple
+ * index where a next group of tuples begins. For example the second
+ * group of tuples in \a comm is described by following range of indices:
+ * [ \a commIndex[1], \a commIndex[2] ). \a commIndex->getNumberOfTuples()-1
+ * gives the number of groups of coincident tuples.
+ * \throw If \a this is not allocated.
+ * \throw If \a this and \a other arrays have different number of tuples.
+ * \throw If the number of components is not in [1,2,3].
+ *
+ * \ref cpp_mcdataarraydouble_findcommontuples "Here is a C++ example".
+ *
+ * \ref py_mcdataarraydouble_findcommontuples "Here is a Python example".
+ * \sa DataArrayInt::BuildOld2NewArrayFromSurjectiveFormat2().
*/
void DataArrayDouble::findCommonTuples(double prec, int limitTupleId, DataArrayInt *&comm, DataArrayInt *&commIndex) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method returns a newly allocated object the user should deal with.
- * This method works for arrays which have number of components into [1,2,3]. If not an exception will be thrown.
- * This method returns the different values in 'this' using 'prec'. The different values are kept in the same
- * order than 'this'. That is to say that returned DataArrayDouble instance is not systematically sorted.
+ * This methods returns the minimal distance between the two set of points \a this and \a other.
+ * So \a this and \a other have to have the same number of components. If not an INTERP_KERNEL::Exception will be thrown.
+ * This method works only if number of components of \a this (equal to those of \a other) is in 1, 2 or 3.
+ *
+ * \param [out] thisTupleId the tuple id in \a this corresponding to the returned minimal distance
+ * \param [out] otherTupleId the tuple id in \a other corresponding to the returned minimal distance
+ * \return the minimal distance between the two set of points \a this and \a other.
+ * \sa DataArrayDouble::findClosestTupleId
+ */
+double DataArrayDouble::minimalDistanceTo(const DataArrayDouble *other, int& thisTupleId, int& otherTupleId) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> part1=findClosestTupleId(other);
+ int nbOfCompo(getNumberOfComponents());
+ int otherNbTuples(other->getNumberOfTuples());
+ const double *thisPt(begin()),*otherPt(other->begin());
+ const int *part1Pt(part1->begin());
+ double ret=std::numeric_limits<double>::max();
+ for(int i=0;i<otherNbTuples;i++,part1Pt++,otherPt+=nbOfCompo)
+ {
+ double tmp(0.);
+ for(int j=0;j<nbOfCompo;j++)
+ tmp+=(otherPt[j]-thisPt[nbOfCompo*(*part1Pt)+j])*(otherPt[j]-thisPt[nbOfCompo*(*part1Pt)+j]);
+ if(tmp<ret)
+ { ret=tmp; thisTupleId=*part1Pt; otherTupleId=i; }
+ }
+ return sqrt(ret);
+}
+
+/*!
+ * This methods returns for each tuple in \a other which tuple in \a this is the closest.
+ * So \a this and \a other have to have the same number of components. If not an INTERP_KERNEL::Exception will be thrown.
+ * This method works only if number of components of \a this (equal to those of \a other) is in 1, 2 or 3.
+ *
+ * \return a newly allocated (new object to be dealt by the caller) DataArrayInt having \c other->getNumberOfTuples() tuples and one components.
+ * \sa DataArrayDouble::minimalDistanceTo
+ */
+DataArrayInt *DataArrayDouble::findClosestTupleId(const DataArrayDouble *other) const throw(INTERP_KERNEL::Exception)
+{
+ if(!other)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::findClosestTupleId : other instance is NULL !");
+ checkAllocated(); other->checkAllocated();
+ int nbOfCompo=getNumberOfComponents();
+ if(nbOfCompo!=other->getNumberOfComponents())
+ {
+ std::ostringstream oss; oss << "DataArrayDouble::findClosestTupleId : number of components in this is " << nbOfCompo;
+ oss << ", whereas number of components in other is " << other->getNumberOfComponents() << "! Should be equal !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ int nbOfTuples=other->getNumberOfTuples();
+ int thisNbOfTuples=getNumberOfTuples();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New(); ret->alloc(nbOfTuples,1);
+ double bounds[6];
+ getMinMaxPerComponent(bounds);
+ switch(nbOfCompo)
+ {
+ case 3:
+ {
+ double xDelta(fabs(bounds[1]-bounds[0])),yDelta(fabs(bounds[3]-bounds[2])),zDelta(fabs(bounds[5]-bounds[4]));
+ double delta=std::max(xDelta,yDelta); delta=std::max(delta,zDelta);
+ double characSize=pow((delta*delta*delta)/((double)thisNbOfTuples),1./3.);
+ BBTreePts<3,int> myTree(begin(),0,0,getNumberOfTuples(),characSize*1e-12);
+ FindClosestTupleIdAlg<3>(myTree,3.*characSize*characSize,other->begin(),nbOfTuples,begin(),thisNbOfTuples,ret->getPointer());
+ break;
+ }
+ case 2:
+ {
+ double xDelta(fabs(bounds[1]-bounds[0])),yDelta(fabs(bounds[3]-bounds[2]));
+ double delta=std::max(xDelta,yDelta);
+ double characSize=sqrt(delta/(double)thisNbOfTuples);
+ BBTreePts<2,int> myTree(begin(),0,0,getNumberOfTuples(),characSize*1e-12);
+ FindClosestTupleIdAlg<2>(myTree,2.*characSize*characSize,other->begin(),nbOfTuples,begin(),thisNbOfTuples,ret->getPointer());
+ break;
+ }
+ case 1:
+ {
+ double characSize=fabs(bounds[1]-bounds[0])/thisNbOfTuples;
+ BBTreePts<1,int> myTree(begin(),0,0,getNumberOfTuples(),characSize*1e-12);
+ FindClosestTupleIdAlg<1>(myTree,1.*characSize*characSize,other->begin(),nbOfTuples,begin(),thisNbOfTuples,ret->getPointer());
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("Unexpected spacedim of coords for findClosestTupleId. Must be 1, 2 or 3.");
+ }
+ return ret.retn();
+}
+
+/*!
+ * Returns a copy of \a this array by excluding coincident tuples. Each tuple is
+ * considered as coordinates of a point in getNumberOfComponents()-dimensional
+ * space. The distance between tuples is computed using norm2. If several tuples are
+ * not far each from other than \a prec, only one of them remains in the result
+ * array. The order of tuples in the result array is same as in \a this one except
+ * that coincident tuples are excluded.
+ * \param [in] prec - minimal absolute distance between two tuples at which they are
+ * considered not coincident.
+ * \param [in] limitTupleId - limit tuple id. Tuples with id strictly lower than \a
+ * limiTupleId are not considered and thus not excluded.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
+ * \throw If the number of components is not in [1,2,3].
*
- * @param prec is an absolute precision.
- * @param limitTupleId is the limit tuple id. All tuples which id is strictly lower than 'limiTupleId' will not be merged each other.
+ * \ref cpp_mcdataarraydouble_getdifferentvalues "Here is a Python example".
*/
DataArrayDouble *DataArrayDouble::getDifferentValues(double prec, int limitTupleId) const throw(INTERP_KERNEL::Exception)
{
return renumberAndReduce(o2n->getConstPointer(),newNbOfTuples);
}
+/*!
+ * Copy all components in a specified order from another DataArrayDouble.
+ * The specified components become the first ones in \a this array.
+ * Both numerical and textual data is copied. The number of tuples in \a this and
+ * the other array can be different.
+ * \param [in] a - the array to copy data from.
+ * \param [in] compoIds - sequence of zero based indices of components, data of which is
+ * to be copied.
+ * \throw If \a a is NULL.
+ * \throw If \a compoIds.size() != \a a->getNumberOfComponents().
+ * \throw If \a compoIds[i] < 0 or \a compoIds[i] > \a this->getNumberOfComponents().
+ *
+ * \ref cpp_mcdataarraydouble_setselectedcomponents "Here is a Python example".
+ */
void DataArrayDouble::setSelectedComponents(const DataArrayDouble *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception)
{
if(!a)
}
/*!
- * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
- * 'strictCompoCompare' specifies if DataArray 'a' should have exactly same number of components and tuples than 'this' (true) or not (false). By default set to true with maximal test.
+ * Copy all values from another DataArrayDouble into specified tuples and components
+ * of \a this array. Textual data is not copied.
+ * The tree parameters defining set of indices of tuples and components are similar to
+ * the tree parameters of the Python function \c range(\c start,\c stop,\c step).
+ * \param [in] a - the array to copy values from.
+ * \param [in] bgTuples - index of the first tuple of \a this array to assign values to.
+ * \param [in] endTuples - index of the tuple before which the tuples to assign to
+ * are located.
+ * \param [in] stepTuples - index increment to get index of the next tuple to assign to.
+ * \param [in] bgComp - index of the first component of \a this array to assign values to.
+ * \param [in] endComp - index of the component before which the components to assign
+ * to are located.
+ * \param [in] stepComp - index increment to get index of the next component to assign to.
+ * \param [in] strictCompoCompare - if \a true (by default), then \a a->getNumberOfComponents()
+ * must be equal to the number of columns to assign to, else an
+ * exception is thrown; if \a false, then it is only required that \a
+ * a->getNbOfElems() equals to number of values to assign to (this condition
+ * must be respected even if \a strictCompoCompare is \a true). The number of
+ * values to assign to is given by following Python expression:
+ * \a nbTargetValues =
+ * \c len(\c range(\a bgTuples,\a endTuples,\a stepTuples)) *
+ * \c len(\c range(\a bgComp,\a endComp,\a stepComp)).
+ * \throw If \a a is NULL.
+ * \throw If \a a is not allocated.
+ * \throw If \a this is not allocated.
+ * \throw If parameters specifying tuples and components to assign to do not give a
+ * non-empty range of increasing indices.
+ * \throw If \a a->getNbOfElems() != \a nbTargetValues.
+ * \throw If \a strictCompoCompare == \a true && \a a->getNumberOfComponents() !=
+ * \c len(\c range(\a bgComp,\a endComp,\a stepComp)).
+ *
+ * \ref cpp_mcdataarraydouble_setpartofvalues1 "Here is a Python example".
*/
void DataArrayDouble::setPartOfValues1(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ * Assign a given value to values at specified tuples and components of \a this array.
+ * The tree parameters defining set of indices of tuples and components are similar to
+ * the tree parameters of the Python function \c range(\c start,\c stop,\c step)..
+ * \param [in] a - the value to assign.
+ * \param [in] bgTuples - index of the first tuple of \a this array to assign to.
+ * \param [in] endTuples - index of the tuple before which the tuples to assign to
+ * are located.
+ * \param [in] stepTuples - index increment to get index of the next tuple to assign to.
+ * \param [in] bgComp - index of the first component of \a this array to assign to.
+ * \param [in] endComp - index of the component before which the components to assign
+ * to are located.
+ * \param [in] stepComp - index increment to get index of the next component to assign to.
+ * \throw If \a this is not allocated.
+ * \throw If parameters specifying tuples and components to assign to, do not give a
+ * non-empty range of increasing indices or indices are out of a valid range
+ * for \this array.
+ *
+ * \ref cpp_mcdataarraydouble_setpartofvaluessimple1 "Here is a Python example".
*/
void DataArrayDouble::setPartOfValuesSimple1(double a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
- * 'strictCompoCompare' specifies if DataArray 'a' should have exactly same number of components and tuples than 'this' (true) or not (false). By default set to true with maximal test.
+ * Copy all values from another DataArrayDouble (\a a) into specified tuples and
+ * components of \a this array. Textual data is not copied.
+ * The tuples and components to assign to are defined by C arrays of indices.
+ * There are two *modes of usage*:
+ * - If \a a->getNbOfElems() equals to number of values to assign to, then every value
+ * of \a a is assigned to its own location within \a this array.
+ * - If \a a includes one tuple, then all values of \a a are assigned to the specified
+ * components of every specified tuple of \a this array. In this mode it is required
+ * that \a a->getNumberOfComponents() equals to the number of specified components.
+ *
+ * \param [in] a - the array to copy values from.
+ * \param [in] bgTuples - pointer to an array of tuple indices of \a this array to
+ * assign values of \a a to.
+ * \param [in] endTuples - specifies the end of the array \a bgTuples, so that
+ * pointer to a tuple index <em>(pi)</em> varies as this:
+ * \a bgTuples <= \a pi < \a endTuples.
+ * \param [in] bgComp - pointer to an array of component indices of \a this array to
+ * assign values of \a a to.
+ * \param [in] endComp - specifies the end of the array \a bgTuples, so that
+ * pointer to a component index <em>(pi)</em> varies as this:
+ * \a bgComp <= \a pi < \a endComp.
+ * \param [in] strictCompoCompare - this parameter is checked only if the
+ * *mode of usage* is the first; if it is \a true (default),
+ * then \a a->getNumberOfComponents() must be equal
+ * to the number of specified columns, else this is not required.
+ * \throw If \a a is NULL.
+ * \throw If \a a is not allocated.
+ * \throw If \a this is not allocated.
+ * \throw If any index of tuple/component given by <em>bgTuples / bgComp</em> is
+ * out of a valid range for \a this array.
+ * \throw In the first *mode of usage*, if <em>strictCompoCompare == true </em> and
+ * if <em> a->getNumberOfComponents() != (endComp - bgComp) </em>.
+ * \throw In the second *mode of usage*, if \a a->getNumberOfTuples() != 1 or
+ * <em> a->getNumberOfComponents() != (endComp - bgComp)</em>.
+ *
+ * \ref cpp_mcdataarraydouble_setpartofvalues2 "Here is a Python example".
*/
void DataArrayDouble::setPartOfValues2(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ * Assign a given value to values at specified tuples and components of \a this array.
+ * The tuples and components to assign to are defined by C arrays of indices.
+ * \param [in] a - the value to assign.
+ * \param [in] bgTuples - pointer to an array of tuple indices of \a this array to
+ * assign \a a to.
+ * \param [in] endTuples - specifies the end of the array \a bgTuples, so that
+ * pointer to a tuple index (\a pi) varies as this:
+ * \a bgTuples <= \a pi < \a endTuples.
+ * \param [in] bgComp - pointer to an array of component indices of \a this array to
+ * assign \a a to.
+ * \param [in] endComp - specifies the end of the array \a bgTuples, so that
+ * pointer to a component index (\a pi) varies as this:
+ * \a bgComp <= \a pi < \a endComp.
+ * \throw If \a this is not allocated.
+ * \throw If any index of tuple/component given by <em>bgTuples / bgComp</em> is
+ * out of a valid range for \a this array.
+ *
+ * \ref cpp_mcdataarraydouble_setpartofvaluessimple2 "Here is a Python example".
*/
void DataArrayDouble::setPartOfValuesSimple2(double a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
- * 'strictCompoCompare' specifies if DataArray 'a' should have exactly same number of components and tuples than 'this' (true) or not (false). By default set to true with maximal test.
+ * Copy all values from another DataArrayDouble (\a a) into specified tuples and
+ * components of \a this array. Textual data is not copied.
+ * The tuples to assign to are defined by a C array of indices.
+ * The components to assign to are defined by three values similar to parameters of
+ * the Python function \c range(\c start,\c stop,\c step).
+ * There are two *modes of usage*:
+ * - If \a a->getNbOfElems() equals to number of values to assign to, then every value
+ * of \a a is assigned to its own location within \a this array.
+ * - If \a a includes one tuple, then all values of \a a are assigned to the specified
+ * components of every specified tuple of \a this array. In this mode it is required
+ * that \a a->getNumberOfComponents() equals to the number of specified components.
+ *
+ * \param [in] a - the array to copy values from.
+ * \param [in] bgTuples - pointer to an array of tuple indices of \a this array to
+ * assign values of \a a to.
+ * \param [in] endTuples - specifies the end of the array \a bgTuples, so that
+ * pointer to a tuple index <em>(pi)</em> varies as this:
+ * \a bgTuples <= \a pi < \a endTuples.
+ * \param [in] bgComp - index of the first component of \a this array to assign to.
+ * \param [in] endComp - index of the component before which the components to assign
+ * to are located.
+ * \param [in] stepComp - index increment to get index of the next component to assign to.
+ * \param [in] strictCompoCompare - this parameter is checked only in the first
+ * *mode of usage*; if \a strictCompoCompare is \a true (default),
+ * then \a a->getNumberOfComponents() must be equal
+ * to the number of specified columns, else this is not required.
+ * \throw If \a a is NULL.
+ * \throw If \a a is not allocated.
+ * \throw If \a this is not allocated.
+ * \throw If any index of tuple given by \a bgTuples is out of a valid range for
+ * \a this array.
+ * \throw In the first *mode of usage*, if <em>strictCompoCompare == true </em> and
+ * if <em> a->getNumberOfComponents()</em> is unequal to the number of components
+ * defined by <em>(bgComp,endComp,stepComp)</em>.
+ * \throw In the second *mode of usage*, if \a a->getNumberOfTuples() != 1 or
+ * <em> a->getNumberOfComponents()</em> is unequal to the number of components
+ * defined by <em>(bgComp,endComp,stepComp)</em>.
+ * \throw If parameters specifying components to assign to, do not give a
+ * non-empty range of increasing indices or indices are out of a valid range
+ * for \this array.
+ *
+ * \ref cpp_mcdataarraydouble_setpartofvalues3 "Here is a Python example".
*/
void DataArrayDouble::setPartOfValues3(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ * Assign a given value to values at specified tuples and components of \a this array.
+ * The tuples to assign to are defined by a C array of indices.
+ * The components to assign to are defined by three values similar to parameters of
+ * the Python function \c range(\c start,\c stop,\c step).
+ * \param [in] a - the value to assign.
+ * \param [in] bgTuples - pointer to an array of tuple indices of \a this array to
+ * assign \a a to.
+ * \param [in] endTuples - specifies the end of the array \a bgTuples, so that
+ * pointer to a tuple index <em>(pi)</em> varies as this:
+ * \a bgTuples <= \a pi < \a endTuples.
+ * \param [in] bgComp - index of the first component of \a this array to assign to.
+ * \param [in] endComp - index of the component before which the components to assign
+ * to are located.
+ * \param [in] stepComp - index increment to get index of the next component to assign to.
+ * \throw If \a this is not allocated.
+ * \throw If any index of tuple given by \a bgTuples is out of a valid range for
+ * \a this array.
+ * \throw If parameters specifying components to assign to, do not give a
+ * non-empty range of increasing indices or indices are out of a valid range
+ * for \this array.
+ *
+ * \ref cpp_mcdataarraydouble_setpartofvaluessimple3 "Here is a Python example".
*/
void DataArrayDouble::setPartOfValuesSimple3(double a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception)
{
}
}
+/*!
+ * Copy all values from another DataArrayDouble into specified tuples and components
+ * of \a this array. Textual data is not copied.
+ * The tree parameters defining set of indices of tuples and components are similar to
+ * the tree parameters of the Python function \c range(\c start,\c stop,\c step).
+ * \param [in] a - the array to copy values from.
+ * \param [in] bgTuples - index of the first tuple of \a this array to assign values to.
+ * \param [in] endTuples - index of the tuple before which the tuples to assign to
+ * are located.
+ * \param [in] stepTuples - index increment to get index of the next tuple to assign to.
+ * \param [in] bgComp - pointer to an array of component indices of \a this array to
+ * assign \a a to.
+ * \param [in] endComp - specifies the end of the array \a bgTuples, so that
+ * pointer to a component index (\a pi) varies as this:
+ * \a bgComp <= \a pi < \a endComp.
+ * \param [in] strictCompoCompare - if \a true (by default), then \a a->getNumberOfComponents()
+ * must be equal to the number of columns to assign to, else an
+ * exception is thrown; if \a false, then it is only required that \a
+ * a->getNbOfElems() equals to number of values to assign to (this condition
+ * must be respected even if \a strictCompoCompare is \a true). The number of
+ * values to assign to is given by following Python expression:
+ * \a nbTargetValues =
+ * \c len(\c range(\a bgTuples,\a endTuples,\a stepTuples)) *
+ * \c len(\c range(\a bgComp,\a endComp,\a stepComp)).
+ * \throw If \a a is NULL.
+ * \throw If \a a is not allocated.
+ * \throw If \a this is not allocated.
+ * \throw If parameters specifying tuples and components to assign to do not give a
+ * non-empty range of increasing indices.
+ * \throw If \a a->getNbOfElems() != \a nbTargetValues.
+ * \throw If \a strictCompoCompare == \a true && \a a->getNumberOfComponents() !=
+ * \c len(\c range(\a bgComp,\a endComp,\a stepComp)).
+ *
+ */
void DataArrayDouble::setPartOfValues4(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
{
if(!a)
}
/*!
- * 'this', 'a' and 'tuplesSelec' are expected to be defined. If not an exception will be thrown.
- * @param a is an array having exactly the same number of components than 'this'
- * @param tuplesSelec is an array having exactly 2 components. The first one refers to the tuple ids of 'this' that will be set. The second one refers to the tuple ids of 'a' that will be used for setting.
+ * Copy some tuples from another DataArrayDouble into specified tuples
+ * of \a this array. Textual data is not copied. Both arrays must have equal number of
+ * components.
+ * Both the tuples to assign and the tuples to assign to are defined by a DataArrayInt.
+ * All components of selected tuples are copied.
+ * \param [in] a - the array to copy values from.
+ * \param [in] tuplesSelec - the array specifying both source tuples of \a a and
+ * target tuples of \a this. \a tuplesSelec has two components, and the
+ * first component specifies index of the source tuple and the second
+ * one specifies index of the target tuple.
+ * \throw If \a this is not allocated.
+ * \throw If \a a is NULL.
+ * \throw If \a a is not allocated.
+ * \throw If \a tuplesSelec is NULL.
+ * \throw If \a tuplesSelec is not allocated.
+ * \throw If <em>this->getNumberOfComponents() != a->getNumberOfComponents()</em>.
+ * \throw If \a tuplesSelec->getNumberOfComponents() != 2.
+ * \throw If any tuple index given by \a tuplesSelec is out of a valid range for
+ * the corresponding (\a this or \a a) array.
*/
void DataArrayDouble::setPartOfValuesAdv(const DataArrayDouble *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * 'this', 'a' and 'tuplesSelec' are expected to be defined. If not an exception will be thrown.
- * This is a method that is a specialization to DataArrayDouble::setPartOfValuesAdv method, except that here the tuple selection of 'a' is given by a range ('bg','end2' and 'step')
- * rather than an explicite array of tuple ids (given by the 2nd component) and the feeding is done in 'this' contiguously starting from 'tupleIdStart'.
- * @param a is an array having exactly the same number of components than 'this'
+ * Copy some tuples from another DataArrayDouble (\a a) into contiguous tuples
+ * of \a this array. Textual data is not copied. Both arrays must have equal number of
+ * components.
+ * The tuples to assign to are defined by index of the first tuple, and
+ * their number is defined by \a tuplesSelec->getNumberOfTuples().
+ * The tuples to copy are defined by values of a DataArrayInt.
+ * All components of selected tuples are copied.
+ * \param [in] tupleIdStart - index of the first tuple of \a this array to assign
+ * values to.
+ * \param [in] a - the array to copy values from.
+ * \param [in] tuplesSelec - the array specifying tuples of \a a to copy.
+ * \throw If \a this is not allocated.
+ * \throw If \a a is NULL.
+ * \throw If \a a is not allocated.
+ * \throw If \a tuplesSelec is NULL.
+ * \throw If \a tuplesSelec is not allocated.
+ * \throw If <em>this->getNumberOfComponents() != a->getNumberOfComponents()</em>.
+ * \throw If \a tuplesSelec->getNumberOfComponents() != 1.
+ * \throw If <em>tupleIdStart + tuplesSelec->getNumberOfTuples() > this->getNumberOfTuples().</em>
+ * \throw If any tuple index given by \a tuplesSelec is out of a valid range for
+ * \a a array.
*/
void DataArrayDouble::setContigPartOfSelectedValues(int tupleIdStart, const DataArrayDouble *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * 'this' and 'a' are expected to be defined. If not an exception will be thrown.
- * This is a method that is a specialization to DataArrayDouble::setContigPartOfSelectedValues method, except that here the tuple selection is givenin a is done by a range ('bg','end2' and 'step')
- * rather than an explicite array of tuple ids.
- * @param a is an array having exactly the same number of components than 'this'
+ * Copy some tuples from another DataArrayDouble (\a a) into contiguous tuples
+ * of \a this array. Textual data is not copied. Both arrays must have equal number of
+ * components.
+ * The tuples to copy are defined by three values similar to parameters of
+ * the Python function \c range(\c start,\c stop,\c step).
+ * The tuples to assign to are defined by index of the first tuple, and
+ * their number is defined by number of tuples to copy.
+ * All components of selected tuples are copied.
+ * \param [in] tupleIdStart - index of the first tuple of \a this array to assign
+ * values to.
+ * \param [in] a - the array to copy values from.
+ * \param [in] bg - index of the first tuple to copy of the array \a a.
+ * \param [in] end2 - index of the tuple of \a a before which the tuples to copy
+ * are located.
+ * \param [in] step - index increment to get index of the next tuple to copy.
+ * \throw If \a this is not allocated.
+ * \throw If \a a is NULL.
+ * \throw If \a a is not allocated.
+ * \throw If <em>this->getNumberOfComponents() != a->getNumberOfComponents()</em>.
+ * \throw If <em>tupleIdStart + len(range(bg,end2,step)) > this->getNumberOfTuples().</em>
+ * \throw If parameters specifying tuples to copy, do not give a
+ * non-empty range of increasing indices or indices are out of a valid range
+ * for the array \a a.
*/
void DataArrayDouble::setContigPartOfSelectedValues2(int tupleIdStart, const DataArrayDouble *a, int bg, int end2, int step) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method is equivalent to DataArrayDouble::getIJ except that here \b tupleId is checked to be in [0,this->getNumberOfTuples()) and compoId to be in [0,this->getNumberOfComponents()).
- * If one of these check fails an INTERP_KERNEL::Exception will be thrown.
- * So this method is safe but expensive if used to go through all data of \b this.
+ * Returns a value located at specified tuple and component.
+ * This method is equivalent to DataArrayDouble::getIJ() except that validity of
+ * parameters is checked. So this method is safe but expensive if used to go through
+ * all values of \a this.
+ * \param [in] tupleId - index of tuple of interest.
+ * \param [in] compoId - index of component of interest.
+ * \return double - value located by \a tupleId and \a compoId.
+ * \throw If \a this is not allocated.
+ * \throw If condition <em>( 0 <= tupleId < this->getNumberOfTuples() )</em> is violated.
+ * \throw If condition <em>( 0 <= compoId < this->getNumberOfComponents() )</em> is violated.
*/
double DataArrayDouble::getIJSafe(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method returns the last element in 'this'. So this method makes the hypothesis that 'this' is allocated.
- * This method works only for arrays that have exactly number of components equal to 1. If not an exception is thrown.
- * And to finish this method works for arrays that have number of tuples >= 1.
+ * Returns the last value of \a this.
+ * \return double - the last value of \a this array.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If \a this->getNumberOfTuples() < 1.
*/
double DataArrayDouble::back() const throw(INTERP_KERNEL::Exception)
{
}
}
+/*!
+ * Sets a C array to be used as raw data of \a this. The previously set info
+ * of components is retained and re-sized.
+ * For more info see \ref MEDCouplingArraySteps1.
+ * \param [in] array - the C array to be used as raw data of \a this.
+ * \param [in] ownership - if \a true, \a array will be deallocated at destruction of \a this.
+ * \param [in] type - specifies how to deallocate \a array. If \a type == ParaMEDMEM::CPP_DEALLOC,
+ * \c delete [] \c array; will be called. If \a type == ParaMEDMEM::C_DEALLOC,
+ * \c free(\c array ) will be called.
+ * \param [in] nbOfTuple - new number of tuples in \a this.
+ * \param [in] nbOfCompo - new number of components in \a this.
+ */
void DataArrayDouble::useArray(const double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo)
{
_info_on_compo.resize(nbOfCompo);
declareAsNew();
}
+/*!
+ * Checks if 0.0 value is present in \a this array. If it is the case, an exception
+ * is thrown.
+ * \throw If zero is found in \a this array.
+ */
void DataArrayDouble::checkNoNullValues() const throw(INTERP_KERNEL::Exception)
{
const double *tmp=getConstPointer();
}
/*!
- * This method assume that \b this is allocated. If not an INTERP_KERNEL::Exception will be thrown.
- * This method fills \b bounds params like that : \b bounds[0]=XMin, \b bounds[1]=XMax, \b bounds[2]=YMin, \b bounds[3]=YMax...
- * Where X refers to component #0, and Y to component #1...
- * This method set 2*this->getNumberOfComponents() elements in \b bounds, so it is up to the caller to allocated enough space before calling this method.
- *
- * @param [out] bounds array of size 2*this->getNumberOfComponents().
+ * Computes minimal and maximal value in each component. An output array is filled
+ * with \c 2 * \a this->getNumberOfComponents() values, so the caller is to allocate
+ * enough memory before calling this method.
+ * \param [out] bounds - array of size at least 2 *\a this->getNumberOfComponents().
+ * It is filled as follows:<br>
+ * \a bounds[0] = \c min_of_component_0 <br>
+ * \a bounds[1] = \c max_of_component_0 <br>
+ * \a bounds[2] = \c min_of_component_1 <br>
+ * \a bounds[3] = \c max_of_component_1 <br>
+ * ...
*/
void DataArrayDouble::getMinMaxPerComponent(double *bounds) const throw(INTERP_KERNEL::Exception)
{
}
}
+/*!
+ * Returns the maximal value and its location within \a this one-dimensional array.
+ * \param [out] tupleId - index of the tuple holding the maximal value.
+ * \return double - the maximal value among all values of \a this array.
+ * \throw If \a this->getNumberOfComponents() != 1
+ * \throw If \a this->getNumberOfTuples() < 1
+ */
double DataArrayDouble::getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
}
/*!
- * Idem to DataArrayDouble::getMaxValue expect that here number of components can be >=1.
+ * Returns the maximal value within \a this array that is allowed to have more than
+ * one component.
+ * \return double - the maximal value among all values of \a this array.
+ * \throw If \a this is not allocated.
*/
double DataArrayDouble::getMaxValueInArray() const throw(INTERP_KERNEL::Exception)
{
return *loc;
}
+/*!
+ * Returns the maximal value and all its locations within \a this one-dimensional array.
+ * \param [out] tupleIds - a new instance of DataArrayInt containg indices of
+ * tuples holding the maximal value. The caller is to delete it using
+ * decrRef() as it is no more needed.
+ * \return double - the maximal value among all values of \a this array.
+ * \throw If \a this->getNumberOfComponents() != 1
+ * \throw If \a this->getNumberOfTuples() < 1
+ */
double DataArrayDouble::getMaxValue2(DataArrayInt*& tupleIds) const throw(INTERP_KERNEL::Exception)
{
int tmp;
return ret;
}
+/*!
+ * Returns the minimal value and its location within \a this one-dimensional array.
+ * \param [out] tupleId - index of the tuple holding the minimal value.
+ * \return double - the minimal value among all values of \a this array.
+ * \throw If \a this->getNumberOfComponents() != 1
+ * \throw If \a this->getNumberOfTuples() < 1
+ */
double DataArrayDouble::getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
}
/*!
- * Idem to DataArrayDouble::getMinValue expect that here number of components can be >=1.
+ * Returns the minimal value within \a this array that is allowed to have more than
+ * one component.
+ * \return double - the minimal value among all values of \a this array.
+ * \throw If \a this is not allocated.
*/
double DataArrayDouble::getMinValueInArray() const throw(INTERP_KERNEL::Exception)
{
return *loc;
}
+/*!
+ * Returns the minimal value and all its locations within \a this one-dimensional array.
+ * \param [out] tupleIds - a new instance of DataArrayInt containg indices of
+ * tuples holding the minimal value. The caller is to delete it using
+ * decrRef() as it is no more needed.
+ * \return double - the minimal value among all values of \a this array.
+ * \throw If \a this->getNumberOfComponents() != 1
+ * \throw If \a this->getNumberOfTuples() < 1
+ */
double DataArrayDouble::getMinValue2(DataArrayInt*& tupleIds) const throw(INTERP_KERNEL::Exception)
{
int tmp;
return ret;
}
+/*!
+ * Returns the average value of \a this one-dimensional array.
+ * \return double - the average value over all values of \a this array.
+ * \throw If \a this->getNumberOfComponents() != 1
+ * \throw If \a this->getNumberOfTuples() < 1
+ */
double DataArrayDouble::getAverageValue() const throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()!=1)
return ret/nbOfTuples;
}
+/*!
+ * Returns the Euclidean norm of the vector defined by \a this array.
+ * \return double - the value of the Euclidean norm, i.e.
+ * the square root of the inner product of vector.
+ * \throw If \a this is not allocated.
+ */
double DataArrayDouble::norm2() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return sqrt(ret);
}
+/*!
+ * Returns the maximum norm of the vector defined by \a this array.
+ * \return double - the value of the maximum norm, i.e.
+ * the maximal absolute value among values of \a this array.
+ * \throw If \a this is not allocated.
+ */
double DataArrayDouble::normMax() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret;
}
+/*!
+ * Accumulates values of each component of \a this array.
+ * \param [out] res - an array of length \a this->getNumberOfComponents(), allocated
+ * by the caller, that is filled by this method with sum value for each
+ * component.
+ * \throw If \a this is not allocated.
+ */
void DataArrayDouble::accumulate(double *res) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return sqrt(ret0);
}
+/*!
+ * Accumulate values of the given component of \a this array.
+ * \param [in] compId - the index of the component of interest.
+ * \return double - a sum value of \a compId-th component.
+ * \throw If \a this is not allocated.
+ * \throw If \a the condition ( 0 <= \a compId < \a this->getNumberOfComponents() ) is
+ * not respected.
+ */
double DataArrayDouble::accumulate(int compId) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret;
}
+/*!
+ * Converts each 2D point defined by the tuple of \a this array from the Polar to the
+ * Cartesian coordinate system. The two components of the tuple of \a this array are
+ * considered to contain (1) radius and (2) angle of the point in the Polar CS.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble, whose each tuple
+ * contains X and Y coordinates of the point in the Cartesian CS. The caller
+ * is to delete this array using decrRef() as it is no more needed. The array
+ * does not contain any textual info on components.
+ * \throw If \a this->getNumberOfComponents() != 2.
+ */
DataArrayDouble *DataArrayDouble::fromPolarToCart() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret;
}
+/*!
+ * Converts each 3D point defined by the tuple of \a this array from the Cylindrical to
+ * the Cartesian coordinate system. The three components of the tuple of \a this array
+ * are considered to contain (1) radius, (2) azimuth and (3) altitude of the point in
+ * the Cylindrical CS.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble, whose each tuple
+ * contains X, Y and Z coordinates of the point in the Cartesian CS. The info
+ * on the third component is copied from \a this array. The caller
+ * is to delete this array using decrRef() as it is no more needed.
+ * \throw If \a this->getNumberOfComponents() != 3.
+ */
DataArrayDouble *DataArrayDouble::fromCylToCart() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret;
}
+/*!
+ * Converts each 3D point defined by the tuple of \a this array from the Spherical to
+ * the Cartesian coordinate system. The three components of the tuple of \a this array
+ * are considered to contain (1) radius, (2) polar angle and (3) azimuthal angle of the
+ * point in the Cylindrical CS.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble, whose each tuple
+ * contains X, Y and Z coordinates of the point in the Cartesian CS. The info
+ * on the third component is copied from \a this array. The caller
+ * is to delete this array using decrRef() as it is no more needed.
+ * \throw If \a this->getNumberOfComponents() != 3.
+ */
DataArrayDouble *DataArrayDouble::fromSpherToCart() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret;
}
+/*!
+ * Computes the doubly contracted product of every tensor defined by the tuple of \a this
+ * array contating 6 components.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble, whose each tuple
+ * is calculated from the tuple <em>(t)</em> of \a this array as follows:
+ * \f$ t[0]^2+t[1]^2+t[2]^2+2*t[3]^2+2*t[4]^2+2*t[5]^2\f$.
+ * The caller is to delete this result array using decrRef() as it is no more needed.
+ * \throw If \a this->getNumberOfComponents() != 6.
+ */
DataArrayDouble *DataArrayDouble::doublyContractedProduct() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret;
}
+/*!
+ * Computes the determinant of every square matrix defined by the tuple of \a this
+ * array, which contains either 4, 6 or 9 components. The case of 6 components
+ * corresponds to that of the upper triangular matrix.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble, whose each tuple
+ * is the determinant of matrix of the corresponding tuple of \a this array.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this->getNumberOfComponents() is not in [4,6,9].
+ */
DataArrayDouble *DataArrayDouble::determinant() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
}
}
+/*!
+ * Computes 3 eigenvalues of every upper triangular matrix defined by the tuple of
+ * \a this array, which contains 6 components.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble containing 3
+ * components, whose each tuple contains the eigenvalues of the matrix of
+ * corresponding tuple of \a this array.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this->getNumberOfComponents() != 6.
+ */
DataArrayDouble *DataArrayDouble::eigenValues() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret;
}
+/*!
+ * Computes 3 eigenvectors of every upper triangular matrix defined by the tuple of
+ * \a this array, which contains 6 components.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble containing 9
+ * components, whose each tuple contains 3 eigenvectors of the matrix of
+ * corresponding tuple of \a this array.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this->getNumberOfComponents() != 6.
+ */
DataArrayDouble *DataArrayDouble::eigenVectors() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret;
}
+/*!
+ * Computes the inverse matrix of every matrix defined by the tuple of \a this
+ * array, which contains either 4, 6 or 9 components. The case of 6 components
+ * corresponds to that of the upper triangular matrix.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble containing the
+ * same number of components as \a this one, whose each tuple is the inverse
+ * matrix of the matrix of corresponding tuple of \a this array.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this->getNumberOfComponents() is not in [4,6,9].
+ */
DataArrayDouble *DataArrayDouble::inverse() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret;
}
+/*!
+ * Computes the trace of every matrix defined by the tuple of \a this
+ * array, which contains either 4, 6 or 9 components. The case of 6 components
+ * corresponds to that of the upper triangular matrix.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble containing
+ * 1 component, whose each tuple is the trace of
+ * the matrix of corresponding tuple of \a this array.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this->getNumberOfComponents() is not in [4,6,9].
+ */
DataArrayDouble *DataArrayDouble::trace() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret;
}
+/*!
+ * Computes the stress deviator tensor of every stress tensor defined by the tuple of
+ * \a this array, which contains 6 components.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble containing the
+ * same number of components and tuples as \a this array.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this->getNumberOfComponents() != 6.
+ */
DataArrayDouble *DataArrayDouble::deviator() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret;
}
+/*!
+ * Computes the magnitude of every vector defined by the tuple of
+ * \a this array.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble containing the
+ * same number of tuples as \a this array and one component.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this is not allocated.
+ */
DataArrayDouble *DataArrayDouble::magnitude() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret;
}
+/*!
+ * Computes the maximal value within every tuple of \a this array.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble containing the
+ * same number of tuples as \a this array and one component.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this is not allocated.
+ */
DataArrayDouble *DataArrayDouble::maxPerTuple() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret.retn();
}
+/*!
+ * Sorts value within every tuple of \a this array.
+ * \param [in] asc - if \a true, the values are sorted in ascending order, else,
+ * in descending order.
+ * \throw If \a this is not allocated.
+ */
void DataArrayDouble::sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception)
{
checkAllocated();
declareAsNew();
}
+/*!
+ * Converts every value of \a this array to its absolute value.
+ * \throw If \a this is not allocated.
+ */
void DataArrayDouble::abs() throw(INTERP_KERNEL::Exception)
{
checkAllocated();
declareAsNew();
}
+/*!
+ * Apply a liner function to a given component of \a this array, so that
+ * an array element <em>(x)</em> becomes \f$ a * x + b \f$.
+ * \param [in] a - the first coefficient of the function.
+ * \param [in] b - the second coefficient of the function.
+ * \param [in] compoId - the index of component to modify.
+ * \throw If \a this is not allocated.
+ */
void DataArrayDouble::applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception)
{
checkAllocated();
declareAsNew();
}
+/*!
+ * Apply a liner function to all elements of \a this array, so that
+ * an element _x_ becomes \f$ a * x + b \f$.
+ * \param [in] a - the first coefficient of the function.
+ * \param [in] b - the second coefficient of the function.
+ * \throw If \a this is not allocated.
+ */
void DataArrayDouble::applyLin(double a, double b) throw(INTERP_KERNEL::Exception)
{
checkAllocated();
}
/*!
- * This method applies the operation 'numerator/x' for each element 'x' in 'this'.
- * If there is a value in 'this' exactly equal to 0. an exception is thrown.
- * Warning if presence of null this is modified for each values previous than place where exception was thrown !
+ * Modify all elements of \a this array, so that
+ * an element _x_ becomes \f$ numerator / x \f$.
+ * \param [in] numerator - the numerator used to modify array elements.
+ * \throw If \a this is not allocated.
+ * \throw If there is an element equal to 0.0 in \a this array.
+ * \warning If an exception is thrown because of presence of 0.0 element in \a this
+ * array, all elements processed before detection of the zero element remain
+ * modified.
*/
void DataArrayDouble::applyInv(double numerator) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method returns a newly allocated array containing the application of negate on \b this.
- * This method throws an INTERP_KERNEL::Exception if \b this is not allocated.
+ * Returns a full copy of \a this array except that sign of all elements is reversed.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble containing the
+ * same number of tuples and component as \a this array.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this is not allocated.
*/
DataArrayDouble *DataArrayDouble::negate() const throw(INTERP_KERNEL::Exception)
{
return newArr;
}
+/*!
+ * Returns a new DataArrayDouble created from \a this one by applying \a
+ * FunctionToEvaluate to every tuple of \a this array. Textual data is not copied.
+ * For more info see \ref MEDCouplingArrayApplyFunc
+ * \param [in] nbOfComp - number of components in the result array.
+ * \param [in] func - the \a FunctionToEvaluate declared as
+ * \c bool (*\a func)(\c const \c double *\a pos, \c double *\a res),
+ * where \a pos points to the first component of a tuple of \a this array
+ * and \a res points to the first component of a tuple of the result array.
+ * Note that length (number of components) of \a pos can differ from
+ * that of \a res.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble containing the
+ * same number of tuples as \a this array.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this is not allocated.
+ * \throw If \a func returns \a false.
+ */
DataArrayDouble *DataArrayDouble::applyFunc(int nbOfComp, FunctionToEvaluate func) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
}
/*!
- * This method returns a newly allocated array the caller should deal with.
- * The returned array will have 'nbOfComp' components (that can be different from this->getNumberOfComponents()) contrary to the other DataArrayDouble::applyFunc overload method.
+ * Returns a new DataArrayDouble created from \a this one by applying a function to every
+ * tuple of \a this array. Textual data is not copied.
+ * For more info see \ref MEDCouplingArrayApplyFunc1.
+ * \param [in] nbOfComp - number of components in the result array.
+ * \param [in] func - the expression defining how to transform a tuple of \a this array.
+ * Supported expressions are described \ref MEDCouplingArrayApplyFuncExpr "here".
+ * \return DataArrayDouble * - the new instance of DataArrayDouble containing the
+ * same number of tuples as \a this array and \a nbOfComp components.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this is not allocated.
+ * \throw If computing \a func fails.
*/
DataArrayDouble *DataArrayDouble::applyFunc(int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception)
{
return newArr;
}
+/*!
+ * Returns a new DataArrayDouble created from \a this one by applying a function to every
+ * tuple of \a this array. Textual data is not copied.
+ * For more info see \ref MEDCouplingArrayApplyFunc0.
+ * \param [in] func - the expression defining how to transform a tuple of \a this array.
+ * Supported expressions are described \ref MEDCouplingArrayApplyFuncExpr "here".
+ * \return DataArrayDouble * - the new instance of DataArrayDouble containing the
+ * same number of tuples and components as \a this array.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this is not allocated.
+ * \throw If computing \a func fails.
+ */
DataArrayDouble *DataArrayDouble::applyFunc(const char *func) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
}
/*!
- * This method is equivalent than DataArrayDouble::applyFunc, except that here components names are used to determine vars orders.
- * If 'func' contains vars that are not in \c this->getInfoOnComponent() an exception will be thrown.
+ * Returns a new DataArrayDouble created from \a this one by applying a function to every
+ * tuple of \a this array. Textual data is not copied.
+ * For more info see \ref MEDCouplingArrayApplyFunc2.
+ * \param [in] nbOfComp - number of components in the result array.
+ * \param [in] func - the expression defining how to transform a tuple of \a this array.
+ * Supported expressions are described \ref MEDCouplingArrayApplyFuncExpr "here".
+ * \return DataArrayDouble * - the new instance of DataArrayDouble containing the
+ * same number of tuples as \a this array.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this is not allocated.
+ * \throw If \a func contains vars that are not in \a this->getInfoOnComponent().
+ * \throw If computing \a func fails.
*/
DataArrayDouble *DataArrayDouble::applyFunc2(int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method is equivalent than DataArrayDouble::applyFunc, except that here order of vars is passed explicitely in parameter.
- * In 'func' contains vars not in 'varsOrder' an exception will be thrown.
+ * Returns a new DataArrayDouble created from \a this one by applying a function to every
+ * tuple of \a this array. Textual data is not copied.
+ * For more info see \ref MEDCouplingArrayApplyFunc3.
+ * \param [in] nbOfComp - number of components in the result array.
+ * \param [in] varsOrder - sequence of vars defining their order.
+ * \param [in] func - the expression defining how to transform a tuple of \a this array.
+ * Supported expressions are described \ref MEDCouplingArrayApplyFuncExpr "here".
+ * \return DataArrayDouble * - the new instance of DataArrayDouble containing the
+ * same number of tuples as \a this array.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this is not allocated.
+ * \throw If \a func contains vars not in \a varsOrder.
+ * \throw If computing \a func fails.
*/
DataArrayDouble *DataArrayDouble::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) const throw(INTERP_KERNEL::Exception)
{
return new DataArrayDoubleIterator(this);
}
+/*!
+ * Returns a new DataArrayInt contating indices of tuples of \a this one-dimensional
+ * array whose values are within a given range. Textual data is not copied.
+ * \param [in] vmin - a lowest acceptable value.
+ * \param [in] vmax - a greatest acceptable value.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this->getNumberOfComponents() != 1
+ *
+ * \ref cpp_mcdataarraydouble_getidsinrange "Here is a C++ example".
+ *
+ * \ref py_mcdataarraydouble_getidsinrange "Here is a Python example".
+ */
DataArrayInt *DataArrayDouble::getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret;
}
+/*!
+ * Returns a new DataArrayDouble by concatenating two given arrays, so that (1) the number
+ * of tuples in the result array is a sum of the number of tuples of given arrays and (2)
+ * the number of component in the result array is same as that of each of given arrays.
+ * Info on components is copied from the first of the given arrays. Number of components
+ * in the given arrays must be the same.
+ * \param [in] a1 - an array to include in the result array.
+ * \param [in] a2 - another array to include in the result array.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If both \a a1 and \a a2 are NULL.
+ * \throw If \a a1->getNumberOfComponents() != \a a2->getNumberOfComponents().
+ */
DataArrayDouble *DataArrayDouble::Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayDouble *> tmp(2);
return Aggregate(tmp);
}
+/*!
+ * Returns a new DataArrayDouble by concatenating all given arrays, so that (1) the number
+ * of tuples in the result array is a sum of the number of tuples of given arrays and (2)
+ * the number of component in the result array is same as that of each of given arrays.
+ * Info on components is copied from the first of the given arrays. Number of components
+ * in the given arrays must be the same.
+ * \param [in] arr - a sequence of arrays to include in the result array.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If all arrays within \a arr are NULL.
+ * \throw If getNumberOfComponents() of arrays within \a arr.
+ */
DataArrayDouble *DataArrayDouble::Aggregate(const std::vector<const DataArrayDouble *>& arr) throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayDouble *> a;
return ret;
}
+/*!
+ * Returns a new DataArrayDouble by aggregating two given arrays, so that (1) the number
+ * of components in the result array is a sum of the number of components of given arrays
+ * and (2) the number of tuples in the result array is same as that of each of given
+ * arrays. In other words the i-th tuple of result array includes all components of
+ * i-th tuples of all given arrays.
+ * Number of tuples in the given arrays must be the same.
+ * \param [in] a1 - an array to include in the result array.
+ * \param [in] a2 - another array to include in the result array.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If both \a a1 and \a a2 are NULL.
+ * \throw If any given array is not allocated.
+ * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples()
+ */
DataArrayDouble *DataArrayDouble::Meld(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayDouble *> arr(2);
return Meld(arr);
}
+/*!
+ * Returns a new DataArrayDouble by aggregating all given arrays, so that (1) the number
+ * of components in the result array is a sum of the number of components of given arrays
+ * and (2) the number of tuples in the result array is same as that of each of given
+ * arrays. In other words the i-th tuple of result array includes all components of
+ * i-th tuples of all given arrays.
+ * Number of tuples in the given arrays must be the same.
+ * \param [in] arr - a sequence of arrays to include in the result array.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If all arrays within \a arr are NULL.
+ * \throw If any given array is not allocated.
+ * \throw If getNumberOfTuples() of arrays within \a arr is different.
+ */
DataArrayDouble *DataArrayDouble::Meld(const std::vector<const DataArrayDouble *>& arr) throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayDouble *> a;
return ret;
}
+/*!
+ * Returns a new DataArrayDouble containing a dot product of two given arrays, so that
+ * the i-th tuple of the result array is a sum of products of j-th components of i-th
+ * tuples of given arrays (\f$ a_i = \sum_{j=1}^n a1_j * a2_j \f$).
+ * Info on components and name is copied from the first of the given arrays.
+ * Number of tuples and components in the given arrays must be the same.
+ * \param [in] a1 - a given array.
+ * \param [in] a2 - another given array.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If either \a a1 or \a a2 is NULL.
+ * \throw If any given array is not allocated.
+ * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples()
+ * \throw If \a a1->getNumberOfComponents() != \a a2->getNumberOfComponents()
+ */
DataArrayDouble *DataArrayDouble::Dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
if(!a1 || !a2)
return ret;
}
+/*!
+ * Returns a new DataArrayDouble containing a cross product of two given arrays, so that
+ * the i-th tuple of the result array contains 3 components of a vector which is a cross
+ * product of two vectors defined by the i-th tuples of given arrays.
+ * Info on components is copied from the first of the given arrays.
+ * Number of tuples in the given arrays must be the same.
+ * Number of components in the given arrays must be 3.
+ * \param [in] a1 - a given array.
+ * \param [in] a2 - another given array.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If either \a a1 or \a a2 is NULL.
+ * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples()
+ * \throw If \a a1->getNumberOfComponents() != 3
+ * \throw If \a a2->getNumberOfComponents() != 3
+ */
DataArrayDouble *DataArrayDouble::CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
if(!a1 || !a2)
return ret;
}
+/*!
+ * Returns a new DataArrayDouble containing maximal values of two given arrays.
+ * Info on components is copied from the first of the given arrays.
+ * Number of tuples and components in the given arrays must be the same.
+ * \param [in] a1 - an array to compare values with another one.
+ * \param [in] a2 - another array to compare values with the first one.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If either \a a1 or \a a2 is NULL.
+ * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples()
+ * \throw If \a a1->getNumberOfComponents() != \a a2->getNumberOfComponents()
+ */
DataArrayDouble *DataArrayDouble::Max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
if(!a1 || !a2)
return ret;
}
+/*!
+ * Returns a new DataArrayDouble containing minimal values of two given arrays.
+ * Info on components is copied from the first of the given arrays.
+ * Number of tuples and components in the given arrays must be the same.
+ * \param [in] a1 - an array to compare values with another one.
+ * \param [in] a2 - another array to compare values with the first one.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If either \a a1 or \a a2 is NULL.
+ * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples()
+ * \throw If \a a1->getNumberOfComponents() != \a a2->getNumberOfComponents()
+ */
DataArrayDouble *DataArrayDouble::Min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
if(!a1 || !a2)
return ret;
}
+/*!
+ * Returns a new DataArrayDouble that is a sum of two given arrays. There are 3
+ * valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * the result array (_a_) is a sum of the corresponding values of \a a1 and \a a2,
+ * i.e.: _a_ [ i, j ] = _a1_ [ i, j ] + _a2_ [ i, j ].
+ * 2. The arrays have same number of tuples and one array, say _a2_, has one
+ * component. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] + _a2_ [ i, 0 ].
+ * 3. The arrays have same number of components and one array, say _a2_, has one
+ * tuple. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] + _a2_ [ 0, j ].
+ *
+ * Info on components is copied either from the first array (in the first case) or from
+ * the array with maximal number of elements (getNbOfElems()).
+ * \param [in] a1 - an array to sum up.
+ * \param [in] a2 - another array to sum up.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If either \a a1 or \a a2 is NULL.
+ * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples() and
+ * \a a1->getNumberOfComponents() != \a a2->getNumberOfComponents() and
+ * none of them has number of tuples or components equal to 1.
+ */
DataArrayDouble *DataArrayDouble::Add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
if(!a1 || !a2)
return ret.retn();
}
+/*!
+ * Adds values of another DataArrayDouble to values of \a this one. There are 3
+ * valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * \a other array is added to the corresponding value of \a this array, i.e.:
+ * _a_ [ i, j ] += _other_ [ i, j ].
+ * 2. The arrays have same number of tuples and \a other array has one component. Then
+ * _a_ [ i, j ] += _other_ [ i, 0 ].
+ * 3. The arrays have same number of components and \a other array has one tuple. Then
+ * _a_ [ i, j ] += _a2_ [ 0, j ].
+ *
+ * \param [in] other - an array to add to \a this one.
+ * \throw If \a other is NULL.
+ * \throw If \a this->getNumberOfTuples() != \a other->getNumberOfTuples() and
+ * \a this->getNumberOfComponents() != \a other->getNumberOfComponents() and
+ * \a other has number of both tuples and components not equal to 1.
+ */
void DataArrayDouble::addEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception)
{
if(!other)
declareAsNew();
}
+/*!
+ * Returns a new DataArrayDouble that is a subtraction of two given arrays. There are 3
+ * valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * the result array (_a_) is a subtraction of the corresponding values of \a a1 and
+ * \a a2, i.e.: _a_ [ i, j ] = _a1_ [ i, j ] - _a2_ [ i, j ].
+ * 2. The arrays have same number of tuples and one array, say _a2_, has one
+ * component. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] - _a2_ [ i, 0 ].
+ * 3. The arrays have same number of components and one array, say _a2_, has one
+ * tuple. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] - _a2_ [ 0, j ].
+ *
+ * Info on components is copied either from the first array (in the first case) or from
+ * the array with maximal number of elements (getNbOfElems()).
+ * \param [in] a1 - an array to subtract from.
+ * \param [in] a2 - an array to subtract.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If either \a a1 or \a a2 is NULL.
+ * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples() and
+ * \a a1->getNumberOfComponents() != \a a2->getNumberOfComponents() and
+ * none of them has number of tuples or components equal to 1.
+ */
DataArrayDouble *DataArrayDouble::Substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
if(!a1 || !a2)
}
}
+/*!
+ * Subtract values of another DataArrayDouble from values of \a this one. There are 3
+ * valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * \a other array is subtracted from the corresponding value of \a this array, i.e.:
+ * _a_ [ i, j ] -= _other_ [ i, j ].
+ * 2. The arrays have same number of tuples and \a other array has one component. Then
+ * _a_ [ i, j ] -= _other_ [ i, 0 ].
+ * 3. The arrays have same number of components and \a other array has one tuple. Then
+ * _a_ [ i, j ] -= _a2_ [ 0, j ].
+ *
+ * \param [in] other - an array to subtract from \a this one.
+ * \throw If \a other is NULL.
+ * \throw If \a this->getNumberOfTuples() != \a other->getNumberOfTuples() and
+ * \a this->getNumberOfComponents() != \a other->getNumberOfComponents() and
+ * \a other has number of both tuples and components not equal to 1.
+ */
void DataArrayDouble::substractEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception)
{
if(!other)
declareAsNew();
}
+/*!
+ * Returns a new DataArrayDouble that is a product of two given arrays. There are 3
+ * valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * the result array (_a_) is a product of the corresponding values of \a a1 and
+ * \a a2, i.e.: _a_ [ i, j ] = _a1_ [ i, j ] * _a2_ [ i, j ].
+ * 2. The arrays have same number of tuples and one array, say _a2_, has one
+ * component. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] * _a2_ [ i, 0 ].
+ * 3. The arrays have same number of components and one array, say _a2_, has one
+ * tuple. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] * _a2_ [ 0, j ].
+ *
+ * Info on components is copied either from the first array (in the first case) or from
+ * the array with maximal number of elements (getNbOfElems()).
+ * \param [in] a1 - a factor array.
+ * \param [in] a2 - another factor array.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If either \a a1 or \a a2 is NULL.
+ * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples() and
+ * \a a1->getNumberOfComponents() != \a a2->getNumberOfComponents() and
+ * none of them has number of tuples or components equal to 1.
+ */
DataArrayDouble *DataArrayDouble::Multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
if(!a1 || !a2)
return ret.retn();
}
+/*!
+ * Multiply values of another DataArrayDouble to values of \a this one. There are 3
+ * valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * \a other array is multiplied to the corresponding value of \a this array, i.e.:
+ * _a_ [ i, j ] *= _other_ [ i, j ].
+ * 2. The arrays have same number of tuples and \a other array has one component. Then
+ * _a_ [ i, j ] *= _other_ [ i, 0 ].
+ * 3. The arrays have same number of components and \a other array has one tuple. Then
+ * _a_ [ i, j ] *= _a2_ [ 0, j ].
+ *
+ * \param [in] other - an array to multiply to \a this one.
+ * \throw If \a other is NULL.
+ * \throw If \a this->getNumberOfTuples() != \a other->getNumberOfTuples() and
+ * \a this->getNumberOfComponents() != \a other->getNumberOfComponents() and
+ * \a other has number of both tuples and components not equal to 1.
+ */
void DataArrayDouble::multiplyEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception)
{
if(!other)
declareAsNew();
}
+/*!
+ * Returns a new DataArrayDouble that is a division of two given arrays. There are 3
+ * valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * the result array (_a_) is a division of the corresponding values of \a a1 and
+ * \a a2, i.e.: _a_ [ i, j ] = _a1_ [ i, j ] / _a2_ [ i, j ].
+ * 2. The arrays have same number of tuples and one array, say _a2_, has one
+ * component. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] / _a2_ [ i, 0 ].
+ * 3. The arrays have same number of components and one array, say _a2_, has one
+ * tuple. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] / _a2_ [ 0, j ].
+ *
+ * Info on components is copied either from the first array (in the first case) or from
+ * the array with maximal number of elements (getNbOfElems()).
+ * \param [in] a1 - a numerator array.
+ * \param [in] a2 - a denominator array.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If either \a a1 or \a a2 is NULL.
+ * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples() and
+ * \a a1->getNumberOfComponents() != \a a2->getNumberOfComponents() and
+ * none of them has number of tuples or components equal to 1.
+ * \warning No check of division by zero is performed!
+ */
DataArrayDouble *DataArrayDouble::Divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
if(!a1 || !a2)
}
}
+/*!
+ * Divide values of \a this array by values of another DataArrayDouble. There are 3
+ * valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * \a this array is divided by the corresponding value of \a other one, i.e.:
+ * _a_ [ i, j ] /= _other_ [ i, j ].
+ * 2. The arrays have same number of tuples and \a other array has one component. Then
+ * _a_ [ i, j ] /= _other_ [ i, 0 ].
+ * 3. The arrays have same number of components and \a other array has one tuple. Then
+ * _a_ [ i, j ] /= _a2_ [ 0, j ].
+ *
+ * \param [in] other - an array to divide \a this one by.
+ * \throw If \a other is NULL.
+ * \throw If \a this->getNumberOfTuples() != \a other->getNumberOfTuples() and
+ * \a this->getNumberOfComponents() != \a other->getNumberOfComponents() and
+ * \a other has number of both tuples and components not equal to 1.
+ * \warning No check of division by zero is performed!
+ */
void DataArrayDouble::divideEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception)
{
if(!other)
}
}
+/*!
+ * Returns a new instance of DataArrayInt. The caller is to delete this array
+ * using decrRef() as it is no more needed.
+ */
DataArrayInt *DataArrayInt::New()
{
return new DataArrayInt;
}
+/*!
+ * Checks if raw data is allocated. Read more on the raw data
+ * in \ref MEDCouplingArrayBasicsTuplesAndCompo "DataArrays infos" for more information.
+ * \return bool - \a true if the raw data is allocated, \a false else.
+ */
bool DataArrayInt::isAllocated() const
{
return getConstPointer()!=0;
}
+/*!
+ * Checks if raw data is allocated and throws an exception if it is not the case.
+ * \throw If the raw data is not allocated.
+ */
void DataArrayInt::checkAllocated() const throw(INTERP_KERNEL::Exception)
{
if(!isAllocated())
}
/*!
- * This method differs from DataArray::setInfoOnComponents in the sense that if 'this->getNumberOfComponents()!=info.size()'
- * and if 'this' is not allocated it will change the number of components of 'this'.
- * If 'this->getNumberOfComponents()==info.size()' the behaviour is the same than DataArray::setInfoOnComponents method.
- * If 'this->getNumberOfComponents()!=info.size()' and the 'this' is already allocated an exception will be thrown.
+ * Sets information on all components. This method can change number of components
+ * at certain conditions; if the conditions are not respected, an exception is thrown.
+ * The number of components can be changed provided that \a this is not allocated.
+ *
+ * To know more on format of the component information see
+ * \ref MEDCouplingArrayBasicsCompoName "DataArrays infos".
+ * \param [in] info - a vector of component infos.
+ * \throw If \a this->getNumberOfComponents() != \a info.size() && \a this->isAllocated()
*/
void DataArrayInt::setInfoAndChangeNbOfCompo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method returns the only one value in 'this', if and only if number of elements (nb of tuples * nb of components) is equal to 1, and that 'this' is allocated.
- * If one or more conditions is not fulfilled an exception will be thrown.
+ * Returns the only one value in \a this, if and only if number of elements
+ * (nb of tuples * nb of components) is equal to 1, and that \a this is allocated.
+ * \return double - the sole value stored in \a this array.
+ * \throw If at least one of conditions stated above is not fulfilled.
*/
int DataArrayInt::intValue() const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method expects that \b this is well allocated. If not an INTERP_KERNEL::Exception will be thrown. This method is useful for a quick comparison of many instances of DataArrayInt.
+ * Returns an integer value characterizing \a this array, which is useful for a quick
+ * comparison of many instances of DataArrayInt.
+ * \return int - the hash value.
+ * \throw If \a this is not allocated.
*/
int DataArrayInt::getHashCode() const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method should be called on an allocated DataArrayInt instance. If not an exception will be throw !
- * This method checks the number of tupes. If it is equal to 0, it returns true, if not false is returned.
+ * Checks the number of tuples.
+ * \return bool - \a true if getNumberOfTuples() == 0, \a false else.
+ * \throw If \a this is not allocated.
*/
bool DataArrayInt::empty() const throw(INTERP_KERNEL::Exception)
{
return getNumberOfTuples()==0;
}
+/*!
+ * Returns a full copy of \a this. For more info on copying data arrays see
+ * \ref MEDCouplingArrayBasicsCopyDeep.
+ * \return DataArrayInt * - a new instance of DataArrayInt.
+ */
DataArrayInt *DataArrayInt::deepCpy() const
{
return new DataArrayInt(*this);
}
+/*!
+ * Returns either a \a deep or \a shallow copy of this array. For more info see
+ * \ref MEDCouplingArrayBasicsCopyDeep and \ref MEDCouplingArrayBasicsCopyShallow.
+ * \param [in] dCpy - if \a true, a deep copy is returned, else, a shallow one.
+ * \return DataArrayInt * - either a new instance of DataArrayInt (if \a dCpy
+ * == \a true) or \a this instance (if \a dCpy == \a false).
+ */
DataArrayInt *DataArrayInt::performCpy(bool dCpy) const
{
if(dCpy)
}
}
+/*!
+ * Copies all the data from another DataArrayInt. For more info see
+ * \ref MEDCouplingArrayBasicsCopyDeepAssign.
+ * \param [in] other - another instance of DataArrayInt to copy data from.
+ * \throw If the \a other is not allocated.
+ */
void DataArrayInt::cpyFrom(const DataArrayInt& other) throw(INTERP_KERNEL::Exception)
{
other.checkAllocated();
copyStringInfoFrom(other);
}
+/*!
+ * This method reserve nbOfElems elements in memory ( nbOfElems*4 bytes ) \b without impacting the number of tuples in \a this.
+ * If \a this has already been allocated, this method checks that \a this has only one component. If not an INTERP_KERNEL::Exception will be thrown.
+ * If \a this has not already been allocated, number of components is set to one.
+ * This method allows to reduce number of reallocations on invokation of DataArrayInt::pushBackSilent and DataArrayInt::pushBackValsSilent on \a this.
+ *
+ * \sa DataArrayInt::pack, DataArrayInt::pushBackSilent, DataArrayInt::pushBackValsSilent
+ */
void DataArrayInt::reserve(int nbOfElems) throw(INTERP_KERNEL::Exception)
{
int nbCompo=getNumberOfComponents();
throw INTERP_KERNEL::Exception("DataArrayInt::reserve : not available for DataArrayInt with number of components different than 1 !");
}
+/*!
+ * This method adds at the end of \a this the single value \a val. This method do \b not update its time label to avoid useless incrementation
+ * of counter. So the caller is expected to call TimeLabel::declareAsNew on \a this at the end of the push session.
+ *
+ * \param [in] val the value to be added in \a this
+ * \throw If \a this has already been allocated with number of components different from one.
+ * \sa DataArrayInt::pushBackValsSilent
+ */
void DataArrayInt::pushBackSilent(int val) throw(INTERP_KERNEL::Exception)
{
int nbCompo=getNumberOfComponents();
throw INTERP_KERNEL::Exception("DataArrayInt::pushBackSilent : not available for DataArrayInt with number of components different than 1 !");
}
+/*!
+ * This method adds at the end of \a this a serie of values [\c valsBg,\c valsEnd). This method do \b not update its time label to avoid useless incrementation
+ * of counter. So the caller is expected to call TimeLabel::declareAsNew on \a this at the end of the push session.
+ *
+ * \param [in] valsBg - an array of values to push at the end of \this.
+ * \param [in] valsEnd - specifies the end of the array \a valsBg, so that
+ * the last value of \a valsBg is \a valsEnd[ -1 ].
+ * \throw If \a this has already been allocated with number of components different from one.
+ * \sa DataArrayInt::pushBackSilent
+ */
void DataArrayInt::pushBackValsSilent(const int *valsBg, const int *valsEnd) throw(INTERP_KERNEL::Exception)
{
int nbCompo=getNumberOfComponents();
throw INTERP_KERNEL::Exception("DataArrayInt::pushBackValsSilent : not available for DataArrayInt with number of components different than 1 !");
}
+/*!
+ * This method returns silently ( without updating time label in \a this ) the last value, if any and suppress it.
+ * \throw If \a this is already empty.
+ * \throw If \a this has number of components different from one.
+ */
int DataArrayInt::popBackSilent() throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()==1)
throw INTERP_KERNEL::Exception("DataArrayInt::popBackSilent : not available for DataArrayInt with number of components different than 1 !");
}
+/*!
+ * This method \b do \b not modify content of \a this. It only modify its memory footprint if the allocated memory is to high regarding real data to store.
+ *
+ * \sa DataArrayInt::getHeapMemorySize, DataArrayInt::reserve
+ */
void DataArrayInt::pack() const throw(INTERP_KERNEL::Exception)
{
_mem.pack();
}
+/*!
+ * Allocates the raw data in memory. If exactly as same memory as needed already
+ * allocated, it is not re-allocated.
+ * \param [in] nbOfTuple - number of tuples of data to allocate.
+ * \param [in] nbOfCompo - number of components of data to allocate.
+ * \throw If \a nbOfTuple < 0 or \a nbOfCompo < 0.
+ */
void DataArrayInt::allocIfNecessary(int nbOfTuple, int nbOfCompo)
{
if(isAllocated())
alloc(nbOfTuple,nbOfCompo);
}
+/*!
+ * Allocates the raw data in memory. If the memory was already allocated, then it is
+ * freed and re-allocated. See an example of this method use
+ * \ref MEDCouplingArraySteps1WC "here".
+ * \param [in] nbOfTuple - number of tuples of data to allocate.
+ * \param [in] nbOfCompo - number of components of data to allocate.
+ * \throw If \a nbOfTuple < 0 or \a nbOfCompo < 0.
+ */
void DataArrayInt::alloc(int nbOfTuple, int nbOfCompo) throw(INTERP_KERNEL::Exception)
{
if(nbOfTuple<0 || nbOfCompo<0)
declareAsNew();
}
+/*!
+ * Assign zero to all values in \a this array. To know more on filling arrays see
+ * \ref MEDCouplingArrayFill.
+ * \throw If \a this is not allocated.
+ */
void DataArrayInt::fillWithZero() throw(INTERP_KERNEL::Exception)
{
checkAllocated();
declareAsNew();
}
+/*!
+ * Assign \a val to all values in \a this array. To know more on filling arrays see
+ * \ref MEDCouplingArrayFill.
+ * \param [in] val - the value to fill with.
+ * \throw If \a this is not allocated.
+ */
void DataArrayInt::fillWithValue(int val) throw(INTERP_KERNEL::Exception)
{
checkAllocated();
declareAsNew();
}
+/*!
+ * Set all values in \a this array so that the i-th element equals to \a init + i
+ * (i starts from zero). To know more on filling arrays see \ref MEDCouplingArrayFill.
+ * \param [in] init - value to assign to the first element of array.
+ * \throw If \a this->getNumberOfComponents() != 1
+ * \throw If \a this is not allocated.
+ */
void DataArrayInt::iota(int init) throw(INTERP_KERNEL::Exception)
{
checkAllocated();
declareAsNew();
}
+/*!
+ * Returns a textual and human readable representation of \a this instance of
+ * DataArrayInt. This text is shown when a DataArrayInt is printed in Python.
+ * \return std::string - text describing \a this DataArrayInt.
+ */
std::string DataArrayInt::repr() const
{
std::ostringstream ret;
}
/*!
- * This method expects a number of components equal to 1.
- * This method sweeps all the values (tuples) in 'this' (it should be allocated) and for each value v is replaced by
- * indArr[v] where 'indArr' is defined by ['indArrBg','indArrEnd').
- * This method is safe that is to say if there is a value in 'this' not in [0,std::distance('indArrBg','indArrEnd')) an exception
- * will be thrown.
+ * Modifies \a this one-dimensional array so that each value \a v = \a indArrBg[ \a v ],
+ * i.e. a current value is used as in index to get a new value from \a indArrBg.
+ * \param [in] indArrBg - pointer to the first element of array of new values to assign
+ * to \a this array.
+ * \param [in] indArrEnd - specifies the end of the array \a indArrBg, so that
+ * the last value of \a indArrBg is \a indArrEnd[ -1 ].
+ * \throw If \a this->getNumberOfComponents() != 1
+ * \throw If any value of \a this can't be used as a valid index for
+ * [\a indArrBg, \a indArrEnd).
*/
void DataArrayInt::transformWithIndArr(const int *indArrBg, const int *indArrEnd) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * 'this' should be allocated and with numberOfComponents set to one. If not an exception will be thrown.
- * This method takes as input an array defined by ['arrBg','arrEnd'). The size of the array (std::distance(arrBg,arrEnd)) is equal to the number of cast + 1.
- * The values contained in ['arrBg','arrEnd') should be sorted ascendently. No check of this will be done. If not the result is not waranted.
- * For each cast j the value range that defines the cast is equal to [arrBg[j],arrBg[j+1]).
- * This method returns three arrays (to be managed by the caller).
- * This method is typically usefull for entity number spliting by types for example.
- * Example : If 'this' contains [6,5,0,3,2,7,8,1,4] and if ['arrBg','arrEnd') contains [0,4,9] then the output of this method will be :
- * - 'castArr' : [1,1,0,0,0,1,1,0,1]
- * - 'rankInsideCast' : [2,1,0,3,2,3,4,1,0]
- * - 'return' : [0,1]
+ * Computes distribution of values of \a this one-dimensional array between given value
+ * ranges (casts). This method is typically useful for entity number spliting by types,
+ * for example.
+ * \param [in] arrBg - the array of ascending values defining the value ranges. The i-th
+ * value of \a arrBg (\a arrBg[ i ]) gives the lowest value of the i-th range,
+ * and the greatest value of the i-th range equals to \a arrBg[ i+1 ] - 1. \a
+ * arrBg containing \a n values defines \a n-1 ranges. The last value of \a arrBg
+ * should be more than every value in \a this array.
+ * \param [in] arrEnd - specifies the end of the array \a arrBg, so that
+ * the last value of \a arrBg is \a arrEnd[ -1 ].
+ * \param [out] castArr - a new instance of DataArrayInt, of same size as \a this array
+ * (same number of tuples and components), the caller is to delete
+ * using decrRef() as it is no more needed.
+ * This array contains indices of ranges for every value of \a this array. I.e.
+ * the i-th value of \a castArr gives the index of range the i-th value of \a this
+ * belongs to. Or, in other words, this parameter contains for each tuple in \a
+ * this in which cast it holds.
+ * \param [out] rankInsideCast - a new instance of DataArrayInt, of same size as \a this
+ * array, the caller is to delete using decrRef() as it is no more needed.
+ * This array contains ranks of values of \a this array within ranges
+ * they belongs to. I.e. the i-th value of \a rankInsideCast gives the rank of
+ * the i-th value of \a this array within the \a castArr[ i ]-th range, to which
+ * the i-th value of \a this belongs to. Or, in other words, this param contains
+ * for each tuple its rank inside its cast. The rank is computed as difference
+ * between the value and the lowest value of range.
+ * \param [out] castsPresent - a new instance of DataArrayInt, containing indices of
+ * ranges (casts) to which at least one value of \a this array belongs.
+ * Or, in other words, this param contains the casts that \a this contains.
+ * The caller is to delete this array using decrRef() as it is no more needed.
*
- * @param castArr is a returned param has the same number of tuples than 'this' and number of components set to one. In case of sucess, this param contains for each tuple in 'this' in which cast it holds.
- * @param rankInsideCast is an another returned param has the same number of tuples than 'this' and number of components set to one too. In case of sucess, this param contains for each tuple its rank inside its cast.
- * @param castsPresent the casts that 'this' contains.
- * @throw if a value in 'this' is greater or equal to the last value of ['arrBg','arrEnd')
+ * \b Example: If \a this contains [6,5,0,3,2,7,8,1,4] and \a arrBg contains [0,4,9] then
+ * the output of this method will be :
+ * - \a castArr : [1,1,0,0,0,1,1,0,1]
+ * - \a rankInsideCast: [2,1,0,3,2,3,4,1,0]
+ * - \a castsPresent : [0,1]
+ *
+ * I.e. values of \a this array belong to 2 ranges: #0 and #1. Value 6 belongs to the
+ * range #1 and its rank within this range is 2; etc.
+ *
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If \a arrEnd - arrBg < 2.
+ * \throw If any value of \a this is not less than \a arrEnd[-1].
+ * \warning The values contained in \a arrBg should be sorted ascendently. No
+ * check of this is be done. If not, the result is not warranted.
+ *
*/
void DataArrayInt::splitByValueRange(const int *arrBg, const int *arrEnd,
DataArrayInt *& castArr, DataArrayInt *& rankInsideCast, DataArrayInt *& castsPresent) const throw(INTERP_KERNEL::Exception)
nbOfCast--;
const int *work=getConstPointer();
typedef std::reverse_iterator<const int *> rintstart;
- rintstart bg(arrEnd);//OK no problem because size of 'arr' is greater of equal 2
+ rintstart bg(arrEnd);//OK no problem because size of 'arr' is greater or equal 2
rintstart end2(arrBg);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret1=DataArrayInt::New();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret2=DataArrayInt::New();
}
/*!
- * This method expects a number of components equal to 1.
- * This method sweeps all the values (tuples) in 'this' (it should be allocated) and for each value v on place i, place indArr[v] will have
- * value i.
- * indArr[v] where 'indArr' is defined by ['indArrBg','indArrEnd').
- * This method is safe that is to say if there is location i so that indArr[v] is not in [0,this->getNumberOfTuples()) an exception
- * will be thrown. An exception is also thrown if there is a location i so that \a this[i] not in [0,distance(indArrBg,indArrEnd)) !
+ * Creates a one-dimensional DataArrayInt (\a res) whose contents are computed from
+ * values of \a this (\a a) and the given (\a indArr) arrays as follows:
+ * \a res[ \a indArr[ \a a[ i ]]] = i. I.e. for each value in place i \a v = \a a[ i ],
+ * new value in place \a indArr[ \a v ] is i.
+ * \param [in] indArrBg - the array holding indices within the result array to assign
+ * indices of values of \a this array pointing to values of \a indArrBg.
+ * \param [in] indArrEnd - specifies the end of the array \a indArrBg, so that
+ * the last value of \a indArrBg is \a indArrEnd[ -1 ].
+ * \return DataArrayInt * - the new instance of DataArrayInt.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If any value of \a this array is not a valid index for \a indArrBg array.
+ * \throw If any value of \a indArrBg is not a valid index for \a this array.
*/
DataArrayInt *DataArrayInt::transformWithIndArrR(const int *indArrBg, const int *indArrEnd) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method invert array 'di' that is a conversion map from Old to New numbering to New to Old numbering.
- * Example : If \a this contains [0,1,2,0,3,4,5,4,6,4] this method will return [3,1,2,4,9,6,8]
+ * Creates a one-dimensional DataArrayInt of given length, whose contents are computed
+ * from values of \a this array, which is supposed to contain a renumbering map in
+ * "Old to New" mode. The result array contains a renumbering map in "New to Old" mode.
+ * To know how to use the renumbering maps see \ref MEDCouplingArrayRenumbering.
+ * \param [in] newNbOfElem - the number of tuples in the result array.
+ * \return DataArrayInt * - the new instance of DataArrayInt.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ *
+ * \ref cpp_mcdataarrayint_invertarrayo2n2n2o "Here is a C++ example".
+ *
+ * \ref py_mcdataarrayint_invertarrayo2n2n2o "Here is a Python example".
*/
DataArrayInt *DataArrayInt::invertArrayO2N2N2O(int newNbOfElem) const
{
}
/*!
- * This method invert array 'di' that is a conversion map from New to old numbering to Old to New numbering.
+ * Creates a one-dimensional DataArrayInt of given length, whose contents are computed
+ * from values of \a this array, which is supposed to contain a renumbering map in
+ * "New to Old" mode. The result array contains a renumbering map in "Old to New" mode.
+ * To know how to use the renumbering maps see \ref MEDCouplingArrayRenumbering.
+ * \param [in] newNbOfElem - the number of tuples in the result array.
+ * \return DataArrayInt * - the new instance of DataArrayInt.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ *
+ * \ref cpp_mcdataarrayint_invertarrayn2o2o2n "Here is a C++ example".
+ *
+ * \ref py_mcdataarrayint_invertarrayn2o2o2n "Here is a Python example".
*/
DataArrayInt *DataArrayInt::invertArrayN2O2O2N(int oldNbOfElem) const
{
return _mem.isEqual(other._mem,0,reason);
}
+/*!
+ * Checks if \a this and another DataArrayInt are fully equal. For more info see
+ * \ref MEDCouplingArrayBasicsCompare.
+ * \param [in] other - an instance of DataArrayInt to compare with \a this one.
+ * \return bool - \a true if the two arrays are equal, \a false else.
+ */
bool DataArrayInt::isEqual(const DataArrayInt& other) const
{
std::string tmp;
return isEqualIfNotWhy(other,tmp);
}
+/*!
+ * Checks if values of \a this and another DataArrayInt are equal. For more info see
+ * \ref MEDCouplingArrayBasicsCompare.
+ * \param [in] other - an instance of DataArrayInt to compare with \a this one.
+ * \return bool - \a true if the values of two arrays are equal, \a false else.
+ */
bool DataArrayInt::isEqualWithoutConsideringStr(const DataArrayInt& other) const
{
std::string tmp;
return _mem.isEqual(other._mem,0,tmp);
}
+/*!
+ * Checks if values of \a this and another DataArrayInt are equal. Comparison is
+ * performed on sorted value sequences.
+ * For more info see\ref MEDCouplingArrayBasicsCompare.
+ * \param [in] other - an instance of DataArrayInt to compare with \a this one.
+ * \return bool - \a true if the sorted values of two arrays are equal, \a false else.
+ */
bool DataArrayInt::isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception)
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> a=deepCpy();
return a->isEqualWithoutConsideringStr(*b);
}
+/*!
+ * Sorts values of the array.
+ * \param [in] asc - \a true means ascending order, \a false, descending.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ */
void DataArrayInt::sort(bool asc) throw(INTERP_KERNEL::Exception)
{
checkAllocated();
_mem.sort(asc);
}
+/*!
+ * Reverse the array values.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If \a this is not allocated.
+ */
void DataArrayInt::reverse() throw(INTERP_KERNEL::Exception)
{
checkAllocated();
}
/*!
- * This method check that array consistently INCREASING or DECREASING in value.
+ * Checks that \a this array is consistently **increasing** or **decreasing** in value.
+ * If not an exception is thrown.
+ * \param [in] increasing - if \a true, the array values should be increasing.
+ * \throw If sequence of values is not strictly monotonic in agreement with \a
+ * increasing arg.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If \a this is not allocated.
*/
void DataArrayInt::checkMonotonic(bool increasing) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method check that array consistently INCREASING or DECREASING in value.
+ * Checks that \a this array is consistently **increasing** or **decreasing** in value.
+ * \param [in] increasing - if \a true, array values should be increasing.
+ * \return bool - \a true if values change in accordance with \a increasing arg.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If \a this is not allocated.
*/
bool DataArrayInt::isMonotonic(bool increasing) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method expects that 'this' and 'other' have the same number of tuples and exactly one component both. If not an exception will be thrown.
- * This method retrieves a newly created array with same number of tuples than 'this' and 'other' with one component.
- * The returned array 'ret' contains the correspondance from 'this' to 'other' that is to say for every i so that 0<=i<getNumberOfTuples()
- * other.getIJ(i,0)==this->getIJ(ret->getIJ(i),0)
- * If such permutation is not possible because it exists some elements in 'other' not in 'this', an exception will be thrown.
+ * Creates a new one-dimensional DataArrayInt of the same size as \a this and a given
+ * one-dimensional arrays that must be of the same length. The result array describes
+ * correspondence between \a this and \a other arrays, so that
+ * <em> other.getIJ(i,0) == this->getIJ(ret->getIJ(i),0)</em>. If such a permutation is
+ * not possible because some element in \a other is not in \a this, an exception is thrown.
+ * \param [in] other - an array to compute permutation to.
+ * \return DataArrayInt * - a new instance of DataArrayInt, which is a permutation array
+ * from \a this to \a other. The caller is to delete this array using decrRef() as it is
+ * no more needed.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If \a other->getNumberOfComponents() != 1.
+ * \throw If \a this->getNumberOfTuples() != \a other->getNumberOfTuples().
+ * \throw If \a other includes a value which is not in \a this array.
+ *
+ * \ref cpp_mcdataarrayint_buildpermutationarr "Here is a C++ example".
+ *
+ * \ref py_mcdataarrayint_buildpermutationarr "Here is a Python example".
*/
DataArrayInt *DataArrayInt::buildPermutationArr(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception)
{
return ret.retn();
}
+/*!
+ * Sets a C array to be used as raw data of \a this. The previously set info
+ * of components is retained and re-sized.
+ * For more info see \ref MEDCouplingArraySteps1.
+ * \param [in] array - the C array to be used as raw data of \a this.
+ * \param [in] ownership - if \a true, \a array will be deallocated at destruction of \a this.
+ * \param [in] type - specifies how to deallocate \a array. If \a type == ParaMEDMEM::CPP_DEALLOC,
+ * \c delete [] \c array; will be called. If \a type == ParaMEDMEM::C_DEALLOC,
+ * \c free(\c array ) will be called.
+ * \param [in] nbOfTuple - new number of tuples in \a this.
+ * \param [in] nbOfCompo - new number of components in \a this.
+ */
void DataArrayInt::useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo)
{
_info_on_compo.resize(nbOfCompo);
declareAsNew();
}
+/*!
+ * Returns a new DataArrayInt holding the same values as \a this array but differently
+ * arranged in memory. If \a this array holds 2 components of 3 values:
+ * \f$ x_0,x_1,x_2,y_0,y_1,y_2 \f$, then the result array holds these values arranged
+ * as follows: \f$ x_0,y_0,x_1,y_1,x_2,y_2 \f$.
+ * \return DataArrayInt * - the new instance of DataArrayInt that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
+ * \warning Do not confuse this method with transpose()!
+ */
DataArrayInt *DataArrayInt::fromNoInterlace() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret;
}
+/*!
+ * Returns a new DataArrayInt holding the same values as \a this array but differently
+ * arranged in memory. If \a this array holds 2 components of 3 values:
+ * \f$ x_0,y_0,x_1,y_1,x_2,y_2 \f$, then the result array holds these values arranged
+ * as follows: \f$ x_0,x_1,x_2,y_0,y_1,y_2 \f$.
+ * \return DataArrayInt * - the new instance of DataArrayInt that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
+ * \warning Do not confuse this method with transpose()!
+ */
DataArrayInt *DataArrayInt::toNoInterlace() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret;
}
+/*!
+ * Permutes values of \a this array as required by \a old2New array. The values are
+ * permuted so that \c new[ \a old2New[ i ]] = \c old[ i ]. Number of tuples remains
+ * the same as in \this one.
+ * If a permutation reduction is needed, substr() or selectByTupleId() should be used.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] old2New - C array of length equal to \a this->getNumberOfTuples()
+ * giving a new position for i-th old value.
+ */
void DataArrayInt::renumberInPlace(const int *old2New)
{
checkAllocated();
declareAsNew();
}
+/*!
+ * Permutes values of \a this array as required by \a new2Old array. The values are
+ * permuted so that \c new[ i ] = \c old[ \a new2Old[ i ]]. Number of tuples remains
+ * the same as in \this one.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] new2Old - C array of length equal to \a this->getNumberOfTuples()
+ * giving a previous position of i-th new value.
+ * \return DataArrayInt * - the new instance of DataArrayInt that the caller
+ * is to delete using decrRef() as it is no more needed.
+ */
void DataArrayInt::renumberInPlaceR(const int *new2Old)
{
checkAllocated();
}
/*!
- * This method expects that 'this' is allocated, if not an exception is thrown.
- * This method in case of success returns a newly created array the user should deal with.
- * In the case of having a renumber array in "old to new" format. More info on renumbering \ref MEDCouplingArrayRenumbering "here".
+ * Returns a copy of \a this array with values permuted as required by \a old2New array.
+ * The values are permuted so that \c new[ \a old2New[ i ]] = \c old[ i ].
+ * Number of tuples in the result array remains the same as in \this one.
+ * If a permutation reduction is needed, renumberAndReduce() should be used.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] old2New - C array of length equal to \a this->getNumberOfTuples()
+ * giving a new position for i-th old value.
+ * \return DataArrayInt * - the new instance of DataArrayInt that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
*/
DataArrayInt *DataArrayInt::renumber(const int *old2New) const
{
return ret;
}
+/*!
+ * Returns a copy of \a this array with values permuted as required by \a new2Old array.
+ * The values are permuted so that \c new[ i ] = \c old[ \a new2Old[ i ]]. Number of
+ * tuples in the result array remains the same as in \this one.
+ * If a permutation reduction is needed, substr() or selectByTupleId() should be used.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] new2Old - C array of length equal to \a this->getNumberOfTuples()
+ * giving a previous position of i-th new value.
+ * \return DataArrayInt * - the new instance of DataArrayInt that the caller
+ * is to delete using decrRef() as it is no more needed.
+ */
DataArrayInt *DataArrayInt::renumberR(const int *new2Old) const
{
checkAllocated();
}
/*!
- * Idem DataArrayInt::renumber method except that the number of tuples is reduced.
- * That is to say that it is expected that newNbOfTuple<this->getNumberOfTuples().
- * ['old2New','old2New'+getNumberOfTuples()) defines a range containing old to new array. For every negative value in ['old2NewBg','old2New'getNumberOfTuples()) the corresponding tuple is
- * omitted.
+ * Returns a shorten and permuted copy of \a this array. The new DataArrayInt is
+ * of size \a newNbOfTuple and it's values are permuted as required by \a old2New array.
+ * The values are permuted so that \c new[ \a old2New[ i ]] = \c old[ i ] for all
+ * \a old2New[ i ] >= 0. In other words every i-th tuple in \a this array, for which
+ * \a old2New[ i ] is negative, is missing from the result array.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] old2New - C array of length equal to \a this->getNumberOfTuples()
+ * giving a new position for i-th old tuple and giving negative position for
+ * for i-th old tuple that should be omitted.
+ * \return DataArrayInt * - the new instance of DataArrayInt that the caller
+ * is to delete using decrRef() as it is no more needed.
*/
DataArrayInt *DataArrayInt::renumberAndReduce(const int *old2New, int newNbOfTuple) const
{
}
/*!
- * This method is a generalization of DataArrayInt::substr method because a not contigous range can be specified here.
- * This method is equavalent to DataArrayInt::renumberAndReduce except that convention in input is new2old and \b not old2new.
+ * Returns a shorten and permuted copy of \a this array. The new DataArrayInt is
+ * of size \a new2OldEnd - \a new2OldBg and it's values are permuted as required by
+ * \a new2OldBg array.
+ * The values are permuted so that \c new[ i ] = \c old[ \a new2OldBg[ i ]].
+ * This method is equivalent to renumberAndReduce() except that convention in input is
+ * \c new2old and \b not \c old2new.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] new2OldBg - pointer to the beginning of a permutation array that gives a
+ * tuple index in \a this array to fill the i-th tuple in the new array.
+ * \param [in] new2OldEnd - specifies the end of the permutation array that starts at
+ * \a new2OldBg, so that pointer to a tuple index (\a pi) varies as this:
+ * \a new2OldBg <= \a pi < \a new2OldEnd.
+ * \return DataArrayInt * - the new instance of DataArrayInt that the caller
+ * is to delete using decrRef() as it is no more needed.
*/
DataArrayInt *DataArrayInt::selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const
{
}
/*!
- * This method is equivalent to DataArrayInt::selectByTupleId except that an analyze to the content of input range to check that it will not lead to memory corruption !
+ * Returns a shorten and permuted copy of \a this array. The new DataArrayInt is
+ * of size \a new2OldEnd - \a new2OldBg and it's values are permuted as required by
+ * \a new2OldBg array.
+ * The values are permuted so that \c new[ i ] = \c old[ \a new2OldBg[ i ]].
+ * This method is equivalent to renumberAndReduce() except that convention in input is
+ * \c new2old and \b not \c old2new.
+ * This method is equivalent to selectByTupleId() except that it prevents coping data
+ * from behind the end of \a this array.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] new2OldBg - pointer to the beginning of a permutation array that gives a
+ * tuple index in \a this array to fill the i-th tuple in the new array.
+ * \param [in] new2OldEnd - specifies the end of the permutation array that starts at
+ * \a new2OldBg, so that pointer to a tuple index (\a pi) varies as this:
+ * \a new2OldBg <= \a pi < \a new2OldEnd.
+ * \return DataArrayInt * - the new instance of DataArrayInt that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a new2OldEnd - \a new2OldBg > \a this->getNumberOfTuples().
*/
DataArrayInt *DataArrayInt::selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * Idem than DataArrayInt::selectByTupleIdSafe except that the input array is not constructed explicitely.
- * The convention is as python one. ['bg','end2') with steps of 'step'.
- * Returns a newly created array.
- * This method is an extension of DataArrayInt::substr method.
- *
- * \sa DataArrayInt::substr
+ * Returns a shorten copy of \a this array. The new DataArrayInt contains every
+ * (\a bg + \c i * \a step)-th tuple of \a this array located before the \a end2-th
+ * tuple. Indices of the selected tuples are the same as ones returned by the Python
+ * command \c range( \a bg, \a end2, \a step ).
+ * This method is equivalent to selectByTupleIdSafe() except that the input array is
+ * not constructed explicitly.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] bg - index of the first tuple to copy from \a this array.
+ * \param [in] end2 - index of the tuple before which the tuples to copy are located.
+ * \param [in] step - index increment to get index of the next tuple to copy.
+ * \return DataArrayInt * - the new instance of DataArrayInt that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If (\a end2 < \a bg) or (\a step <= 0).
+ * \sa DataArrayInt::substr.
*/
DataArrayInt *DataArrayInt::selectByTupleId2(int bg, int end2, int step) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method returns a newly allocated array that is the concatenation of all tuples ranges in param 'ranges'.
- * Each pair in input 'ranges' is in [begin,end) format. If there is a range in 'ranges' so that end is before begin an exception
- * will be thrown. If there is a range in 'ranges' so that end is greater than number of tuples of 'this', an exception will be thrown too.
+ * Returns a shorten copy of \a this array. The new DataArrayInt contains ranges
+ * of tuples specified by \a ranges parameter.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] ranges - std::vector of std::pair's each of which defines a range
+ * of tuples in [\c begin,\c end) format.
+ * \return DataArrayInt * - the new instance of DataArrayInt that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a end < \a begin.
+ * \throw If \a end > \a this->getNumberOfTuples().
+ * \throw If \a this is not allocated.
*/
DataArrayInt *DataArrayInt::selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method works only for arrays having single component.
- * If this contains the array a1 containing [9,10,0,6,4,11,3,7] this method returns an array a2 [5,6,0,3,2,7,1,4].
- * By doing a1.renumber(a2) the user will obtain array a3 equal to a1 sorted.
- * This method is useful for renumbering (in MED file for example). This method is used by MEDCouplingFieldInt::renumberCells when check is set to true.
- * This method throws an exception if more 2 or more elements in 'this' are same.
+ * Returns a new DataArrayInt containing a renumbering map in "Old to New" mode.
+ * This map, if applied to \a this array, would make it sorted. For example, if
+ * \a this array contents are [9,10,0,6,4,11,3,7] then the contents of the result array
+ * are [5,6,0,3,2,7,1,4]; if this result array (\a res) is used as an argument in call
+ * \a this->renumber(\a res) then the returned array contains [0,3,4,6,7,9,10,11].
+ * This method is useful for renumbering (in MED file for example). For more info
+ * on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
+ * array using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If there are equal values in \a this array.
*/
DataArrayInt *DataArrayInt::checkAndPreparePermutation() const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method makes the assumption that 'this' is correctly set, and has exactly one component. If not an exception will be thrown.
- * Given a sujective application defined by 'this' from a set of size this->getNumberOfTuples() to a set of size targetNb.
- * 'targetNb'<this->getNumberOfTuples(). 'this' should be surjective that is to say for each id in [0,'targetNb') it exists at least one tupleId tid
- * so that this->getIJ(tid,0)==id.
- * If not an exception will be thrown.
- * This method returns 2 newly allocated arrays 'arr' and 'arrI', corresponding respectively to array and its corresponding index.
- * This method is usefull for methods that returns old2New numbering concecutive to a reduction ( MEDCouplingUMesh::zipConnectivityTraducer, MEDCouplingUMesh::zipConnectivityTraducer for example)
- * Example : if 'this' equals [0,3,2,3,2,2,1,2] this method will return arrI=[0,1,2,6,8] arr=[0, 6, 2,4,5,7, 1,3]
- * That is to say elt id 2 has arrI[2+1]-arrI[2]=4 places in 'this'. The corresponding tuple ids are [2,4,5,7].
+ * Returns two arrays describing a surjective mapping from \a this set of values (\a A)
+ * onto a set of values of size \a targetNb (\a B). The surjective function is
+ * \a B[ \a A[ i ]] = i. That is to say that for each \a id in [0,\a targetNb), where \a
+ * targetNb < \a this->getNumberOfTuples(), there exists at least one tupleId (\a tid) so
+ * that <em> this->getIJ( tid, 0 ) == id</em>. <br>
+ * The first of out arrays returns indices of elements of \a this array, grouped by their
+ * place in the set \a B. The second out array is the index of the first one; it shows how
+ * many elements of \a A are mapped into each element of \a B. <br>
+ * For more info on
+ * mapping and its usage in renumbering see \ref MEDCouplingArrayRenumbering. <br>
+ * \b Example:
+ * - \a this: [0,3,2,3,2,2,1,2]
+ * - \a targetNb: 4
+ * - \a arr: [0, 6, 2,4,5,7, 1,3]
+ * - \a arrI: [0,1,2,6,8]
+ *
+ * This result means: <br>
+ * the element of \a B 0 encounters within \a A once (\a arrI[ 0+1 ] - \a arrI[ 0 ]) and
+ * its index within \a A is 0 ( \a arr[ 0:1 ] == \a arr[ \a arrI[ 0 ] : \a arrI[ 0+1 ]]);<br>
+ * the element of \a B 2 encounters within \a A 4 times (\a arrI[ 2+1 ] - \a arrI[ 2 ]) and
+ * its indices within \a A are [2,4,5,7] ( \a arr[ 2:6 ] == \a arr[ \a arrI[ 2 ] :
+ * \a arrI[ 2+1 ]]); <br> etc.
+ * \param [in] targetNb - the size of the set \a B. \a targetNb must be equal or more
+ * than the maximal value of \a A.
+ * \param [out] arr - a new instance of DataArrayInt returning indices of
+ * elements of \a this, grouped by their place in the set \a B. The caller is to delete
+ * this array using decrRef() as it is no more needed.
+ * \param [out] arrI - a new instance of DataArrayInt returning size of groups of equal
+ * elements of \a this. The caller is to delete this array using decrRef() as it
+ * is no more needed.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If any value in \a this is more or equal to \a targetNb.
*/
void DataArrayInt::changeSurjectiveFormat(int targetNb, DataArrayInt *&arr, DataArrayInt *&arrI) const throw(INTERP_KERNEL::Exception)
{
arrI=retI.retn();
}
+
/*!
- * This static method computes a old 2 new format DataArrayInt instance from a zip representation of a surjective format (retrived by DataArrayInt::findCommonTuples for example)
- * The retrieved array minimizes the permutation.
- * Let's take an example :
- * If 'nbOfOldTuples'==10 and 'arr'==[0,3, 5,7,9] and 'arrI'==[0,2,5] it returns the following array [0,1,2,0,3,4,5,4,6,4] and newNbOfTuples==7.
+ * Returns a new DataArrayInt containing a renumbering map in "Old to New" mode computed
+ * from a zip representation of a surjective format (returned e.g. by
+ * \ref ParaMEDMEM::DataArrayDouble::findCommonTuples() "DataArrayDouble::findCommonTuples()"
+ * for example). The result array minimizes the permutation. <br>
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering. <br>
+ * \b Example: <br>
+ * - \a nbOfOldTuples: 10
+ * - \a arr : [0,3, 5,7,9]
+ * - \a arrIBg : [0,2,5]
+ * - \a newNbOfTuples: 7
+ * - result array : [0,1,2,0,3,4,5,4,6,4]
*
- * @param nbOfOldTuples is the number of tuples in initial array.
- * @param arr is the list of tuples ids grouped by 'arrI' array
- * @param arrIBg is the entry point of 'arr' array. arrI->getNumberOfTuples()-1 is the number of common groups > 1 tuple.
- * @param arrIEnd is the entry point of 'arr' array (end not included)
- * @param newNbOfTuples output parameter that retrieves the new number of tuples after surjection application
+ * \param [in] nbOfOldTuples - number of tuples in the initial array \a arr.
+ * \param [in] arr - the array of tuple indices grouped by \a arrIBg array.
+ * \param [in] arrIBg - the array dividing all indices stored in \a arr into groups of
+ * (indices of) equal values. Its every element (except the last one) points to
+ * the first element of a group of equal values.
+ * \param [in] arrIEnd - specifies the end of \a arrIBg, so that the last element of \a
+ * arrIBg is \a arrIEnd[ -1 ].
+ * \param [out] newNbOfTuples - number of tuples after surjection application.
+ * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
+ * array using decrRef() as it is no more needed.
+ * \throw If any value of \a arr breaks condition ( 0 <= \a arr[ i ] < \a nbOfOldTuples ).
*/
DataArrayInt *DataArrayInt::BuildOld2NewArrayFromSurjectiveFormat2(int nbOfOldTuples, const int *arr, const int *arrIBg, const int *arrIEnd, int &newNbOfTuples) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method expects that 'this' is allocated and with only one component. If not an exception will be thrown.
- * This method returns a newly created array with 'this->getNumberOfTuples()' tuples and 1 component.
- * This methods returns an 'old2New' corresponding array that allows to follow the following rules :
- * - Lower a value in tuple in 'this' is, higher is its priority.
- * - If two tuples i and j have same value if i<j then ret[i]<ret[j]
- * - The first tuple with the lowest value will have the value 0, inversely the last tuple with highest value will have value 'this->getNumberOfTuples()-1'
- *
- * Example if 'this' contains the following array : [2,0,1,1,0,1,2,0,1,1,0,0] this method returns [10,0,5,6,1,7,11,2,8,9,3,4]
+ * Returns a new DataArrayInt containing a renumbering map in "New to Old" mode,
+ * which if applied to \a this array would make it sorted ascendingly.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering. <br>
+ * \b Example: <br>
+ * - \a this: [2,0,1,1,0,1,2,0,1,1,0,0]
+ * - result: [10,0,5,6,1,7,11,2,8,9,3,4]
+ * - after applying result to \a this: [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2]
+ *
+ * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
+ * array using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
*/
DataArrayInt *DataArrayInt::buildPermArrPerLevel() const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method checks that 'this' is with numberofcomponents == 1 and that it is equal to
- * stdext::iota() of size getNumberOfTuples. This method is particalary usefull for DataArrayInt instances
- * that represents a renumbering array to check the real need in renumbering.
+ * Checks if contents of \a this array are equal to that of an array filled with
+ * iota(). This method is particularly useful for DataArrayInt instances that represent
+ * a renumbering array to check the real need in renumbering.
+ * \return bool - \a true if \a this array contents == \a range( \a this->getNumberOfTuples())
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
*/
bool DataArrayInt::isIdentity() const throw(INTERP_KERNEL::Exception)
{
return true;
}
+/*!
+ * Checks if all values in \a this array are equal to \a val.
+ * \param [in] val - value to check equality of array values to.
+ * \return bool - \a true if all values are \a val.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1
+ */
bool DataArrayInt::isUniform(int val) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return true;
}
+/*!
+ * Creates a new DataArrayDouble and assigns all (textual and numerical) data of \a this
+ * array to the new one.
+ * \return DataArrayDouble * - the new instance of DataArrayInt.
+ */
DataArrayDouble *DataArrayInt::convertToDblArr() const
{
checkAllocated();
}
/*!
- * This methods has a similar behaviour than std::string::substr. This method returns a newly created DataArrayInt that is part of this with same number of components.
- * The intervall is specified by [tupleIdBg,tupleIdEnd) except if tupleIdEnd ==-1 in this case the [tupleIdBg,this->end()) will be kept.
- * This method check that interval is valid regarding this, if not an exception will be thrown.
- * This method is a specialization of method DataArrayInt::selectByTupleId2.
- *
- * \sa DataArrayInt::selectByTupleId2
+ * Returns a shorten copy of \a this array. The new DataArrayInt contains all
+ * tuples starting from the \a tupleIdBg-th tuple and including all tuples located before
+ * the \a tupleIdEnd-th one. This methods has a similar behavior as std::string::substr().
+ * This method is a specialization of selectByTupleId2().
+ * \param [in] tupleIdBg - index of the first tuple to copy from \a this array.
+ * \param [in] tupleIdEnd - index of the tuple before which the tuples to copy are located.
+ * If \a tupleIdEnd == -1, all the tuples till the end of \a this array are copied.
+ * \return DataArrayInt * - the new instance of DataArrayInt that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a tupleIdBg < 0.
+ * \throw If \a tupleIdBg > \a this->getNumberOfTuples().
+ \throw If \a tupleIdEnd != -1 && \a tupleIdEnd < \a this->getNumberOfTuples().
+ * \sa DataArrayInt::selectByTupleId2
*/
DataArrayInt *DataArrayInt::substr(int tupleIdBg, int tupleIdEnd) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * Contrary to DataArrayInt::changeNbOfComponents method this method is \b not const. The content
- * This method \b do \b not change the content of data but changes the splitting of this data seen by the caller.
- * This method makes the assumption that 'this' is already allocated. If not an exception will be thrown.
- * This method checks that getNbOfElems()%newNbOfCompo==0. If not an exception will be throw !
- * This method erases all components info set before call !
+ * Changes the number of components within \a this array so that its raw data **does
+ * not** change, instead splitting this data into tuples changes.
+ * \param [in] newNbOfComp - number of components for \a this array to have.
+ * \throw If \a this is not allocated
+ * \throw If getNbOfElems() % \a newNbOfCompo != 0.
+ * \warning This method erases all (name and unit) component info set before!
*/
void DataArrayInt::rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method makes the assumption that \b this is allocated. If not an INTERP_KERNEL::Exception will be raised.
- * This method does not echange the values stored in \b this. Simply, the number of components before the call becomes the number of
- * tuples and inversely the number of tuples becomes the number of components. \b WARNING the info on components can be alterated by this method.
+ * Changes the number of components within \a this array to be equal to its number
+ * of tuples, and inversely its number of tuples to become equal to its number of
+ * components. So that its raw data **does not** change, instead splitting this
+ * data into tuples changes.
+ * \throw If \a this is not allocated.
+ * \warning This method erases all (name and unit) component info set before!
+ * \warning Do not confuse this method with fromNoInterlace() and toNoInterlace()!
+ * \sa rearrange()
*/
void DataArrayInt::transpose() throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method builds a new instance of DataArrayInt (to deal with) that is reduction or an extension of 'this'.
- * if 'newNbOfComp' < this->getNumberOfComponents() a reduction is done and for each tuple 'newNbOfComp' first components are kept.
- * If 'newNbOfComp' > this->getNumberOfComponents() an extension is done, and for each components i such that i > getNumberOfComponents() 'dftValue' parameter is taken.
+ * Returns a shorten or extended copy of \a this array. If \a newNbOfComp is less
+ * than \a this->getNumberOfComponents() then the result array is shorten as each tuple
+ * is truncated to have \a newNbOfComp components, keeping first components. If \a
+ * newNbOfComp is more than \a this->getNumberOfComponents() then the result array is
+ * expanded as each tuple is populated with \a dftValue to have \a newNbOfComp
+ * components.
+ * \param [in] newNbOfComp - number of components for the new array to have.
+ * \param [in] dftValue - value assigned to new values added to the new array.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
*/
DataArrayInt *DataArrayInt::changeNbOfComponents(int newNbOfComp, int dftValue) const throw(INTERP_KERNEL::Exception)
{
return ret;
}
+/*!
+ * Changes number of tuples in the array. If the new number of tuples is smaller
+ * than the current number the array is truncated, otherwise the array is extended.
+ * \param [in] nbOfTuples - new number of tuples.
+ * \throw If \a this is not allocated.
+ */
void DataArrayInt::reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception)
{
checkAllocated();
declareAsNew();
}
+
+/*!
+ * Returns a copy of \a this array composed of selected components.
+ * The new DataArrayInt has the same number of tuples but includes components
+ * specified by \a compoIds parameter. So that getNbOfElems() of the result array
+ * can be either less, same or more than \a this->getNbOfElems().
+ * \param [in] compoIds - sequence of zero based indices of components to include
+ * into the new array.
+ * \return DataArrayInt * - the new instance of DataArrayInt that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
+ * \throw If a component index (\a i) is not valid:
+ * \a i < 0 || \a i >= \a this->getNumberOfComponents().
+ *
+ * \ref cpp_mcdataarrayint_keepselectedcomponents "Here is a Python example".
+ */
DataArrayInt *DataArrayInt::keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
}
/*!
- * This method melds the components of 'this' with components of 'other'.
- * After this call in case of success, 'this' will contain a number of components equal to the sum of 'this'
- * before the call and the number of components of 'other'.
- * This method expects that 'this' and 'other' have exactly the same number of tuples. If not an exception is thrown.
+ * Appends components of another array to components of \a this one, tuple by tuple.
+ * So that the number of tuples of \a this array remains the same and the number of
+ * components increases.
+ * \param [in] other - the DataArrayInt to append to \a this one.
+ * \throw If \a this is not allocated.
+ * \throw If \a this and \a other arrays have different number of tuples.
+ *
+ * \ref cpp_mcdataarrayint_meldwith "Here is a C++ example".
+ *
+ * \ref py_mcdataarrayint_meldwith "Here is a Python example".
*/
void DataArrayInt::meldWith(const DataArrayInt *other) throw(INTERP_KERNEL::Exception)
{
copyPartOfStringInfoFrom2(compIds,*other);
}
+/*!
+ * Copy all components in a specified order from another DataArrayInt.
+ * The specified components become the first ones in \a this array.
+ * Both numerical and textual data is copied. The number of tuples in \a this and
+ * the other array can be different.
+ * \param [in] a - the array to copy data from.
+ * \param [in] compoIds - sequence of zero based indices of components, data of which is
+ * to be copied.
+ * \throw If \a a is NULL.
+ * \throw If \a compoIds.size() != \a a->getNumberOfComponents().
+ * \throw If \a compoIds[i] < 0 or \a compoIds[i] > \a this->getNumberOfComponents().
+ *
+ * \ref cpp_mcdataarrayint_setselectedcomponents "Here is a Python example".
+ */
void DataArrayInt::setSelectedComponents(const DataArrayInt *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception)
{
if(!a)
}
/*!
- * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
- * 'strictCompoCompare' specifies if DataArray 'a' should have exactly same number of components and tuples than 'this' (true) or not (false). By default set to true with maximal test.
+ * Copy all values from another DataArrayInt into specified tuples and components
+ * of \a this array. Textual data is not copied.
+ * The tree parameters defining set of indices of tuples and components are similar to
+ * the tree parameters of the Python function \c range(\c start,\c stop,\c step).
+ * \param [in] a - the array to copy values from.
+ * \param [in] bgTuples - index of the first tuple of \a this array to assign values to.
+ * \param [in] endTuples - index of the tuple before which the tuples to assign to
+ * are located.
+ * \param [in] stepTuples - index increment to get index of the next tuple to assign to.
+ * \param [in] bgComp - index of the first component of \a this array to assign values to.
+ * \param [in] endComp - index of the component before which the components to assign
+ * to are located.
+ * \param [in] stepComp - index increment to get index of the next component to assign to.
+ * \param [in] strictCompoCompare - if \a true (by default), then \a a->getNumberOfComponents()
+ * must be equal to the number of columns to assign to, else an
+ * exception is thrown; if \a false, then it is only required that \a
+ * a->getNbOfElems() equals to number of values to assign to (this condition
+ * must be respected even if \a strictCompoCompare is \a true). The number of
+ * values to assign to is given by following Python expression:
+ * \a nbTargetValues =
+ * \c len(\c range(\a bgTuples,\a endTuples,\a stepTuples)) *
+ * \c len(\c range(\a bgComp,\a endComp,\a stepComp)).
+ * \throw If \a a is NULL.
+ * \throw If \a a is not allocated.
+ * \throw If \a this is not allocated.
+ * \throw If parameters specifying tuples and components to assign to do not give a
+ * non-empty range of increasing indices.
+ * \throw If \a a->getNbOfElems() != \a nbTargetValues.
+ * \throw If \a strictCompoCompare == \a true && \a a->getNumberOfComponents() !=
+ * \c len(\c range(\a bgComp,\a endComp,\a stepComp)).
+ *
+ * \ref cpp_mcdataarrayint_setpartofvalues1 "Here is a Python example".
*/
void DataArrayInt::setPartOfValues1(const DataArrayInt *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ * Assign a given value to values at specified tuples and components of \a this array.
+ * The tree parameters defining set of indices of tuples and components are similar to
+ * the tree parameters of the Python function \c range(\c start,\c stop,\c step)..
+ * \param [in] a - the value to assign.
+ * \param [in] bgTuples - index of the first tuple of \a this array to assign to.
+ * \param [in] endTuples - index of the tuple before which the tuples to assign to
+ * are located.
+ * \param [in] stepTuples - index increment to get index of the next tuple to assign to.
+ * \param [in] bgComp - index of the first component of \a this array to assign to.
+ * \param [in] endComp - index of the component before which the components to assign
+ * to are located.
+ * \param [in] stepComp - index increment to get index of the next component to assign to.
+ * \throw If \a this is not allocated.
+ * \throw If parameters specifying tuples and components to assign to, do not give a
+ * non-empty range of increasing indices or indices are out of a valid range
+ * for \this array.
+ *
+ * \ref cpp_mcdataarrayint_setpartofvaluessimple1 "Here is a Python example".
*/
void DataArrayInt::setPartOfValuesSimple1(int a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception)
{
pt[j*stepComp]=a;
}
+
/*!
- * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
- * 'strictCompoCompare' specifies if DataArray 'a' should have exactly same number of components and tuples than 'this' (true) or not (false). By default set to true with maximal test.
+ * Copy all values from another DataArrayInt (\a a) into specified tuples and
+ * components of \a this array. Textual data is not copied.
+ * The tuples and components to assign to are defined by C arrays of indices.
+ * There are two *modes of usage*:
+ * - If \a a->getNbOfElems() equals to number of values to assign to, then every value
+ * of \a a is assigned to its own location within \a this array.
+ * - If \a a includes one tuple, then all values of \a a are assigned to the specified
+ * components of every specified tuple of \a this array. In this mode it is required
+ * that \a a->getNumberOfComponents() equals to the number of specified components.
+ *
+ * \param [in] a - the array to copy values from.
+ * \param [in] bgTuples - pointer to an array of tuple indices of \a this array to
+ * assign values of \a a to.
+ * \param [in] endTuples - specifies the end of the array \a bgTuples, so that
+ * pointer to a tuple index <em>(pi)</em> varies as this:
+ * \a bgTuples <= \a pi < \a endTuples.
+ * \param [in] bgComp - pointer to an array of component indices of \a this array to
+ * assign values of \a a to.
+ * \param [in] endComp - specifies the end of the array \a bgTuples, so that
+ * pointer to a component index <em>(pi)</em> varies as this:
+ * \a bgComp <= \a pi < \a endComp.
+ * \param [in] strictCompoCompare - this parameter is checked only if the
+ * *mode of usage* is the first; if it is \a true (default),
+ * then \a a->getNumberOfComponents() must be equal
+ * to the number of specified columns, else this is not required.
+ * \throw If \a a is NULL.
+ * \throw If \a a is not allocated.
+ * \throw If \a this is not allocated.
+ * \throw If any index of tuple/component given by <em>bgTuples / bgComp</em> is
+ * out of a valid range for \a this array.
+ * \throw In the first *mode of usage*, if <em>strictCompoCompare == true </em> and
+ * if <em> a->getNumberOfComponents() != (endComp - bgComp) </em>.
+ * \throw In the second *mode of usage*, if \a a->getNumberOfTuples() != 1 or
+ * <em> a->getNumberOfComponents() != (endComp - bgComp)</em>.
+ *
+ * \ref cpp_mcdataarrayint_setpartofvalues2 "Here is a Python example".
*/
void DataArrayInt::setPartOfValues2(const DataArrayInt *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ * Assign a given value to values at specified tuples and components of \a this array.
+ * The tuples and components to assign to are defined by C arrays of indices.
+ * \param [in] a - the value to assign.
+ * \param [in] bgTuples - pointer to an array of tuple indices of \a this array to
+ * assign \a a to.
+ * \param [in] endTuples - specifies the end of the array \a bgTuples, so that
+ * pointer to a tuple index (\a pi) varies as this:
+ * \a bgTuples <= \a pi < \a endTuples.
+ * \param [in] bgComp - pointer to an array of component indices of \a this array to
+ * assign \a a to.
+ * \param [in] endComp - specifies the end of the array \a bgTuples, so that
+ * pointer to a component index (\a pi) varies as this:
+ * \a bgComp <= \a pi < \a endComp.
+ * \throw If \a this is not allocated.
+ * \throw If any index of tuple/component given by <em>bgTuples / bgComp</em> is
+ * out of a valid range for \a this array.
+ *
+ * \ref cpp_mcdataarrayint_setpartofvaluessimple2 "Here is a Python example".
*/
void DataArrayInt::setPartOfValuesSimple2(int a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
- * 'strictCompoCompare' specifies if DataArray 'a' should have exactly same number of components and tuples than 'this' (true) or not (false). By default set to true with maximal test.
+ * Copy all values from another DataArrayInt (\a a) into specified tuples and
+ * components of \a this array. Textual data is not copied.
+ * The tuples to assign to are defined by a C array of indices.
+ * The components to assign to are defined by three values similar to parameters of
+ * the Python function \c range(\c start,\c stop,\c step).
+ * There are two *modes of usage*:
+ * - If \a a->getNbOfElems() equals to number of values to assign to, then every value
+ * of \a a is assigned to its own location within \a this array.
+ * - If \a a includes one tuple, then all values of \a a are assigned to the specified
+ * components of every specified tuple of \a this array. In this mode it is required
+ * that \a a->getNumberOfComponents() equals to the number of specified components.
+ *
+ * \param [in] a - the array to copy values from.
+ * \param [in] bgTuples - pointer to an array of tuple indices of \a this array to
+ * assign values of \a a to.
+ * \param [in] endTuples - specifies the end of the array \a bgTuples, so that
+ * pointer to a tuple index <em>(pi)</em> varies as this:
+ * \a bgTuples <= \a pi < \a endTuples.
+ * \param [in] bgComp - index of the first component of \a this array to assign to.
+ * \param [in] endComp - index of the component before which the components to assign
+ * to are located.
+ * \param [in] stepComp - index increment to get index of the next component to assign to.
+ * \param [in] strictCompoCompare - this parameter is checked only in the first
+ * *mode of usage*; if \a strictCompoCompare is \a true (default),
+ * then \a a->getNumberOfComponents() must be equal
+ * to the number of specified columns, else this is not required.
+ * \throw If \a a is NULL.
+ * \throw If \a a is not allocated.
+ * \throw If \a this is not allocated.
+ * \throw If any index of tuple given by \a bgTuples is out of a valid range for
+ * \a this array.
+ * \throw In the first *mode of usage*, if <em>strictCompoCompare == true </em> and
+ * if <em> a->getNumberOfComponents()</em> is unequal to the number of components
+ * defined by <em>(bgComp,endComp,stepComp)</em>.
+ * \throw In the second *mode of usage*, if \a a->getNumberOfTuples() != 1 or
+ * <em> a->getNumberOfComponents()</em> is unequal to the number of components
+ * defined by <em>(bgComp,endComp,stepComp)</em>.
+ * \throw If parameters specifying components to assign to, do not give a
+ * non-empty range of increasing indices or indices are out of a valid range
+ * for \this array.
+ *
+ * \ref cpp_mcdataarrayint_setpartofvalues3 "Here is a Python example".
*/
void DataArrayInt::setPartOfValues3(const DataArrayInt *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ * Assign a given value to values at specified tuples and components of \a this array.
+ * The tuples to assign to are defined by a C array of indices.
+ * The components to assign to are defined by three values similar to parameters of
+ * the Python function \c range(\c start,\c stop,\c step).
+ * \param [in] a - the value to assign.
+ * \param [in] bgTuples - pointer to an array of tuple indices of \a this array to
+ * assign \a a to.
+ * \param [in] endTuples - specifies the end of the array \a bgTuples, so that
+ * pointer to a tuple index <em>(pi)</em> varies as this:
+ * \a bgTuples <= \a pi < \a endTuples.
+ * \param [in] bgComp - index of the first component of \a this array to assign to.
+ * \param [in] endComp - index of the component before which the components to assign
+ * to are located.
+ * \param [in] stepComp - index increment to get index of the next component to assign to.
+ * \throw If \a this is not allocated.
+ * \throw If any index of tuple given by \a bgTuples is out of a valid range for
+ * \a this array.
+ * \throw If parameters specifying components to assign to, do not give a
+ * non-empty range of increasing indices or indices are out of a valid range
+ * for \this array.
+ *
+ * \ref cpp_mcdataarrayint_setpartofvaluessimple3 "Here is a Python example".
*/
void DataArrayInt::setPartOfValuesSimple3(int a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * 'this', 'a' and 'tuplesSelec' are expected to be defined. If not an exception will be thrown.
- * @param a is an array having exactly the same number of components than 'this'
- * @param tuplesSelec is an array having exactly 2 components. The first one refers to the tuple ids of 'this' that will be set. The second one refers to the tuple ids of 'a' that will be used for setting.
+ * Copy some tuples from another DataArrayInt into specified tuples
+ * of \a this array. Textual data is not copied. Both arrays must have equal number of
+ * components.
+ * Both the tuples to assign and the tuples to assign to are defined by a DataArrayInt.
+ * All components of selected tuples are copied.
+ * \param [in] a - the array to copy values from.
+ * \param [in] tuplesSelec - the array specifying both source tuples of \a a and
+ * target tuples of \a this. \a tuplesSelec has two components, and the
+ * first component specifies index of the source tuple and the second
+ * one specifies index of the target tuple.
+ * \throw If \a this is not allocated.
+ * \throw If \a a is NULL.
+ * \throw If \a a is not allocated.
+ * \throw If \a tuplesSelec is NULL.
+ * \throw If \a tuplesSelec is not allocated.
+ * \throw If <em>this->getNumberOfComponents() != a->getNumberOfComponents()</em>.
+ * \throw If \a tuplesSelec->getNumberOfComponents() != 2.
+ * \throw If any tuple index given by \a tuplesSelec is out of a valid range for
+ * the corresponding (\a this or \a a) array.
*/
void DataArrayInt::setPartOfValuesAdv(const DataArrayInt *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * 'this', 'a' and 'tuplesSelec' are expected to be defined. If not an exception will be thrown.
- * This is a method that is a specialization to DataArrayInt::setPartOfValuesAdv method, except that here the tuple selection of 'a' is given by a range ('bg','end2' and 'step')
- * rather than an explicite array of tuple ids (given by the 2nd component) and the feeding is done in 'this' contiguously starting from 'tupleIdStart'.
- * @param a is an array having exactly the same number of components than 'this'
+ * Copy some tuples from another DataArrayInt (\a a) into contiguous tuples
+ * of \a this array. Textual data is not copied. Both arrays must have equal number of
+ * components.
+ * The tuples to assign to are defined by index of the first tuple, and
+ * their number is defined by \a tuplesSelec->getNumberOfTuples().
+ * The tuples to copy are defined by values of a DataArrayInt.
+ * All components of selected tuples are copied.
+ * \param [in] tupleIdStart - index of the first tuple of \a this array to assign
+ * values to.
+ * \param [in] a - the array to copy values from.
+ * \param [in] tuplesSelec - the array specifying tuples of \a a to copy.
+ * \throw If \a this is not allocated.
+ * \throw If \a a is NULL.
+ * \throw If \a a is not allocated.
+ * \throw If \a tuplesSelec is NULL.
+ * \throw If \a tuplesSelec is not allocated.
+ * \throw If <em>this->getNumberOfComponents() != a->getNumberOfComponents()</em>.
+ * \throw If \a tuplesSelec->getNumberOfComponents() != 1.
+ * \throw If <em>tupleIdStart + tuplesSelec->getNumberOfTuples() > this->getNumberOfTuples().</em>
+ * \throw If any tuple index given by \a tuplesSelec is out of a valid range for
+ * \a a array.
*/
void DataArrayInt::setContigPartOfSelectedValues(int tupleIdStart, const DataArrayInt*a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * 'this' and 'a' are expected to be defined. If not an exception will be thrown.
- * This is a method that is a specialization to DataArrayInt::setContigPartOfSelectedValues method, except that here the tuple selection is givenin a is done by a range ('bg','end2' and 'step')
- * rather than an explicite array of tuple ids.
- * @param a is an array having exactly the same number of components than 'this'
+ * Copy some tuples from another DataArrayInt (\a a) into contiguous tuples
+ * of \a this array. Textual data is not copied. Both arrays must have equal number of
+ * components.
+ * The tuples to copy are defined by three values similar to parameters of
+ * the Python function \c range(\c start,\c stop,\c step).
+ * The tuples to assign to are defined by index of the first tuple, and
+ * their number is defined by number of tuples to copy.
+ * All components of selected tuples are copied.
+ * \param [in] tupleIdStart - index of the first tuple of \a this array to assign
+ * values to.
+ * \param [in] a - the array to copy values from.
+ * \param [in] bg - index of the first tuple to copy of the array \a a.
+ * \param [in] end2 - index of the tuple of \a a before which the tuples to copy
+ * are located.
+ * \param [in] step - index increment to get index of the next tuple to copy.
+ * \throw If \a this is not allocated.
+ * \throw If \a a is NULL.
+ * \throw If \a a is not allocated.
+ * \throw If <em>this->getNumberOfComponents() != a->getNumberOfComponents()</em>.
+ * \throw If <em>tupleIdStart + len(range(bg,end2,step)) > this->getNumberOfTuples().</em>
+ * \throw If parameters specifying tuples to copy, do not give a
+ * non-empty range of increasing indices or indices are out of a valid range
+ * for the array \a a.
*/
void DataArrayInt::setContigPartOfSelectedValues2(int tupleIdStart, const DataArrayInt *a, int bg, int end2, int step) throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method is equivalent to DataArrayInt::getIJ except that here \b tupleId is checked to be in [0,this->getNumberOfTuples()) and compoId to be in [0,this->getNumberOfComponents()).
- * If one of these check fails an INTERP_KERNEL::Exception will be thrown.
- * So this method is safe but expensive if used to go through all data of \b this.
+ * Returns a value located at specified tuple and component.
+ * This method is equivalent to DataArrayInt::getIJ() except that validity of
+ * parameters is checked. So this method is safe but expensive if used to go through
+ * all values of \a this.
+ * \param [in] tupleId - index of tuple of interest.
+ * \param [in] compoId - index of component of interest.
+ * \return double - value located by \a tupleId and \a compoId.
+ * \throw If \a this is not allocated.
+ * \throw If condition <em>( 0 <= tupleId < this->getNumberOfTuples() )</em> is violated.
+ * \throw If condition <em>( 0 <= compoId < this->getNumberOfComponents() )</em> is violated.
*/
int DataArrayInt::getIJSafe(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method returns the last element in 'this'. So this method makes the hypothesis that 'this' is allocated.
- * This method works only for arrays that have exactly number of components equal to 1. If not an exception is thrown.
- * And to finish this method works for arrays that have number of tuples >= 1.
+ * Returns the last value of \a this.
+ * \return double - the last value of \a this array.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If \a this->getNumberOfTuples() < 1.
*/
int DataArrayInt::back() const throw(INTERP_KERNEL::Exception)
{
return *(getConstPointer()+nbOfTuples-1);
}
+/*!
+ * Assign pointer to one array to a pointer to another appay. Reference counter of
+ * \a arrayToSet is incremented / decremented.
+ * \param [in] newArray - the pointer to array to assign to \a arrayToSet.
+ * \param [in,out] arrayToSet - the pointer to array to assign to.
+ */
void DataArrayInt::SetArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet)
{
if(newArray!=arrayToSet)
return new DataArrayIntIterator(this);
}
+/*!
+ * Creates a new DataArrayInt containing IDs (indices) of tuples holding value equal to a
+ * given one.
+ * \param [in] val - the value to find within \a this.
+ * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
+ * array using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ */
DataArrayInt *DataArrayInt::getIdsEqual(int val) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret.retn();
}
+/*!
+ * Creates a new DataArrayInt containing IDs (indices) of tuples holding value \b not
+ * equal to a given one.
+ * \param [in] val - the value to ignore within \a this.
+ * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
+ * array using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ */
DataArrayInt *DataArrayInt::getIdsNotEqual(int val) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret.retn();
}
+
/*!
- * This method expects that 'this' is allocated. If not an exception will be thrown.
- * This method expect that the number of components is exactly equal to 1. If not an exception will be thrown.
- * For each element in 'this' equal to 'oldValue' will take the value 'newValue'.
- * @return number of elements impacted by the modification.
+ * Assigns \a newValue to all elements holding \a oldValue within \a this
+ * one-dimensional array.
+ * \param [in] oldValue - the value to replace.
+ * \param [in] newValue - the value to assign.
+ * \return int - number of replacements performed.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
*/
int DataArrayInt::changeValue(int oldValue, int newValue) throw(INTERP_KERNEL::Exception)
{
return ret;
}
+/*!
+ * Creates a new DataArrayInt containing IDs (indices) of tuples holding value equal to
+ * one of given values.
+ * \param [in] valsBg - an array of values to find within \a this array.
+ * \param [in] valsEnd - specifies the end of the array \a valsBg, so that
+ * the last value of \a valsBg is \a valsEnd[ -1 ].
+ * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
+ * array using decrRef() as it is no more needed.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ */
DataArrayInt *DataArrayInt::getIdsEqualList(const int *valsBg, const int *valsEnd) const throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()!=1)
const int *cptr=getConstPointer();
std::vector<int> res;
int nbOfTuples=getNumberOfTuples();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(0,1);
for(int i=0;i<nbOfTuples;i++,cptr++)
if(vals2.find(*cptr)!=vals2.end())
- res.push_back(i);
- DataArrayInt *ret=DataArrayInt::New();
- ret->alloc((int)res.size(),1);
- std::copy(res.begin(),res.end(),ret->getPointer());
- return ret;
+ ret->pushBackSilent(i);
+ return ret.retn();
}
+/*!
+ * Creates a new DataArrayInt containing IDs (indices) of tuples holding values \b not
+ * equal to any of given values.
+ * \param [in] valsBg - an array of values to ignore within \a this array.
+ * \param [in] valsEnd - specifies the end of the array \a valsBg, so that
+ * the last value of \a valsBg is \a valsEnd[ -1 ].
+ * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
+ * array using decrRef() as it is no more needed.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ */
DataArrayInt *DataArrayInt::getIdsNotEqualList(const int *valsBg, const int *valsEnd) const throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()!=1)
const int *cptr=getConstPointer();
std::vector<int> res;
int nbOfTuples=getNumberOfTuples();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(0,1);
for(int i=0;i<nbOfTuples;i++,cptr++)
if(vals2.find(*cptr)==vals2.end())
- res.push_back(i);
- DataArrayInt *ret=DataArrayInt::New();
- ret->alloc((int)res.size(),1);
- std::copy(res.begin(),res.end(),ret->getPointer());
- return ret;
+ ret->pushBackSilent(i);
+ return ret.retn();
}
/*!
return locateTuple(tupl)!=-1;
}
+
/*!
- * This method expects to be called when number of components of this is equal to one.
- * This method returns true if it exists a tuple equal to \b value.
- * If not any tuple contains \b value false is returned.
- * \sa DataArrayInt::locateValue
+ * Returns \a true if a given value is present within \a this one-dimensional array.
+ * \param [in] value - the value to find within \a this array.
+ * \return bool - \a true in case if \a value is present within \a this array.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \sa locateValue()
*/
bool DataArrayInt::presenceOfValue(int value) const throw(INTERP_KERNEL::Exception)
{
return locateValue(vals)!=-1;
}
-
+/*!
+ * Accumulates values of each component of \a this array.
+ * \param [out] res - an array of length \a this->getNumberOfComponents(), allocated
+ * by the caller, that is filled by this method with sum value for each
+ * component.
+ * \throw If \a this is not allocated.
+ */
void DataArrayInt::accumulate(int *res) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret;
}
+/*!
+ * Returns a new DataArrayInt by concatenating two given arrays, so that (1) the number
+ * of tuples in the result array is <em> a1->getNumberOfTuples() + a2->getNumberOfTuples() -
+ * offsetA2</em> and (2)
+ * the number of component in the result array is same as that of each of given arrays.
+ * First \a offsetA2 tuples of \a a2 are skipped and thus are missing from the result array.
+ * Info on components is copied from the first of the given arrays. Number of components
+ * in the given arrays must be the same.
+ * \param [in] a1 - an array to include in the result array.
+ * \param [in] a2 - another array to include in the result array.
+ * \param [in] offsetA2 - number of tuples of \a a2 to skip.
+ * \return DataArrayInt * - the new instance of DataArrayInt.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If either \a a1 or \a a2 is NULL.
+ * \throw If \a a1->getNumberOfComponents() != \a a2->getNumberOfComponents().
+ */
DataArrayInt *DataArrayInt::Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2)
{
if(!a1 || !a2)
return ret;
}
+/*!
+ * Returns a new DataArrayInt by concatenating all given arrays, so that (1) the number
+ * of tuples in the result array is a sum of the number of tuples of given arrays and (2)
+ * the number of component in the result array is same as that of each of given arrays.
+ * Info on components is copied from the first of the given arrays. Number of components
+ * in the given arrays must be the same.
+ * \param [in] arr - a sequence of arrays to include in the result array.
+ * \return DataArrayInt * - the new instance of DataArrayInt.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If all arrays within \a arr are NULL.
+ * \throw If getNumberOfComponents() of arrays within \a arr.
+ */
DataArrayInt *DataArrayInt::Aggregate(const std::vector<const DataArrayInt *>& arr) throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayInt *> a;
return ret;
}
+/*!
+ * Returns the maximal value and its location within \a this one-dimensional array.
+ * \param [out] tupleId - index of the tuple holding the maximal value.
+ * \return double - the maximal value among all values of \a this array.
+ * \throw If \a this->getNumberOfComponents() != 1
+ * \throw If \a this->getNumberOfTuples() < 1
+ */
int DataArrayInt::getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
}
/*!
- * Idem to DataArrayInt::getMaxValue expect that here number of components can be >=1.
+ * Returns the maximal value within \a this array that is allowed to have more than
+ * one component.
+ * \return int - the maximal value among all values of \a this array.
+ * \throw If \a this is not allocated.
*/
int DataArrayInt::getMaxValueInArray() const throw(INTERP_KERNEL::Exception)
{
return *loc;
}
+/*!
+ * Returns the minimal value and its location within \a this one-dimensional array.
+ * \param [out] tupleId - index of the tuple holding the minimal value.
+ * \return int - the minimal value among all values of \a this array.
+ * \throw If \a this->getNumberOfComponents() != 1
+ * \throw If \a this->getNumberOfTuples() < 1
+ */
int DataArrayInt::getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
}
/*!
- * Idem to DataArrayInt::getMinValue expect that here number of components can be >=1.
+ * Returns the minimal value within \a this array that is allowed to have more than
+ * one component.
+ * \return int - the minimal value among all values of \a this array.
+ * \throw If \a this is not allocated.
*/
int DataArrayInt::getMinValueInArray() const throw(INTERP_KERNEL::Exception)
{
return *loc;
}
+/*!
+ * Converts every value of \a this array to its absolute value.
+ * \throw If \a this is not allocated.
+ */
void DataArrayInt::abs() throw(INTERP_KERNEL::Exception)
{
checkAllocated();
declareAsNew();
}
+/*!
+ * Apply a liner function to a given component of \a this array, so that
+ * an array element <em>(x)</em> becomes \f$ a * x + b \f$.
+ * \param [in] a - the first coefficient of the function.
+ * \param [in] b - the second coefficient of the function.
+ * \param [in] compoId - the index of component to modify.
+ * \throw If \a this is not allocated.
+ */
void DataArrayInt::applyLin(int a, int b, int compoId) throw(INTERP_KERNEL::Exception)
{
checkAllocated();
declareAsNew();
}
+/*!
+ * Apply a liner function to all elements of \a this array, so that
+ * an element _x_ becomes \f$ a * x + b \f$.
+ * \param [in] a - the first coefficient of the function.
+ * \param [in] b - the second coefficient of the function.
+ * \throw If \a this is not allocated.
+ */
void DataArrayInt::applyLin(int a, int b) throw(INTERP_KERNEL::Exception)
{
checkAllocated();
}
/*!
- * This method returns a newly allocated array containing the application of negate on \b this.
- * This method throws an INTERP_KERNEL::Exception if \b this is not allocated.
+ * Returns a full copy of \a this array except that sign of all elements is reversed.
+ * \return DataArrayInt * - the new instance of DataArrayInt containing the
+ * same number of tuples and component as \a this array.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this is not allocated.
*/
DataArrayInt *DataArrayInt::negate() const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method applies the operation 'numerator/x' for each element 'x' in 'this'.
- * If there is a value in 'this' exactly equal to 0. an exception is thrown.
- * Warning if presence of null this is modified for each values previous than place where exception was thrown !
+ * Modify all elements of \a this array, so that
+ * an element _x_ becomes \f$ numerator / x \f$.
+ * \param [in] numerator - the numerator used to modify array elements.
+ * \throw If \a this is not allocated.
+ * \throw If there is an element equal to 0 in \a this array.
+ * \warning If an exception is thrown because of presence of 0 element in \a this
+ * array, all elements processed before detection of the zero element remain
+ * modified.
*/
void DataArrayInt::applyInv(int numerator) throw(INTERP_KERNEL::Exception)
{
declareAsNew();
}
+/*!
+ * Modify all elements of \a this array, so that
+ * an element _x_ becomes \f$ x / val \f$.
+ * \param [in] val - the denominator used to modify array elements.
+ * \throw If \a this is not allocated.
+ * \throw If \a val == 0.
+ */
void DataArrayInt::applyDivideBy(int val) throw(INTERP_KERNEL::Exception)
{
if(val==0)
declareAsNew();
}
+/*!
+ * Modify all elements of \a this array, so that
+ * an element _x_ becomes <em> x % val </em>.
+ * \param [in] val - the divisor used to modify array elements.
+ * \throw If \a this is not allocated.
+ * \throw If \a val <= 0.
+ */
void DataArrayInt::applyModulus(int val) throw(INTERP_KERNEL::Exception)
{
if(val<=0)
}
/*!
- * This method applies the operation 'numerator%x' for each element 'x' in 'this'.
- * If there is a value in 'this' exactly equals or lower than 0. an exception is thrown.
- * Warning if presence of null this is modified for each values previous than place where exception was thrown !
+ * Modify all elements of \a this array, so that
+ * an element _x_ becomes <em> val % x </em>.
+ * \param [in] val - the divident used to modify array elements.
+ * \throw If \a this is not allocated.
+ * \throw If there is an element equal to or less than 0 in \a this array.
+ * \warning If an exception is thrown because of presence of an element <= 0 in \a this
+ * array, all elements processed before detection of the zero element remain
+ * modified.
*/
void DataArrayInt::applyRModulus(int val) throw(INTERP_KERNEL::Exception)
{
declareAsNew();
}
+/*!
+ * Returns a new DataArrayInt by aggregating two given arrays, so that (1) the number
+ * of components in the result array is a sum of the number of components of given arrays
+ * and (2) the number of tuples in the result array is same as that of each of given
+ * arrays. In other words the i-th tuple of result array includes all components of
+ * i-th tuples of all given arrays.
+ * Number of tuples in the given arrays must be the same.
+ * \param [in] a1 - an array to include in the result array.
+ * \param [in] a2 - another array to include in the result array.
+ * \return DataArrayInt * - the new instance of DataArrayInt.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If both \a a1 and \a a2 are NULL.
+ * \throw If any given array is not allocated.
+ * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples()
+ */
DataArrayInt *DataArrayInt::Meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayInt *> arr(2);
return Meld(arr);
}
+/*!
+ * Returns a new DataArrayInt by aggregating all given arrays, so that (1) the number
+ * of components in the result array is a sum of the number of components of given arrays
+ * and (2) the number of tuples in the result array is same as that of each of given
+ * arrays. In other words the i-th tuple of result array includes all components of
+ * i-th tuples of all given arrays.
+ * Number of tuples in the given arrays must be the same.
+ * \param [in] arr - a sequence of arrays to include in the result array.
+ * \return DataArrayInt * - the new instance of DataArrayInt.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If all arrays within \a arr are NULL.
+ * \throw If any given array is not allocated.
+ * \throw If getNumberOfTuples() of arrays within \a arr is different.
+ */
DataArrayInt *DataArrayInt::Meld(const std::vector<const DataArrayInt *>& arr) throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayInt *> a;
}
/*!
- * This method create a minimal partition of groups 'groups' the std::iota array of size 'newNb'.
- * This method returns an array of size 'newNb' that specifies for each item at which familyId it owns to, and this method returns
- * for each group the familyId it contains. If an id so that id<newNb and that appears in no groups will appears with 0 in return array.
+ * Returns a new DataArrayInt which is a minimal partition of elements of \a groups.
+ * The i-th item of the result array is an ID of a set of elements belonging to a
+ * unique set of groups, which the i-th element is a part of. This set of elements
+ * belonging to a unique set of groups is called \a family, so the result array contains
+ * IDs of families each element belongs to.
+ *
+ * \b Example: if we have two groups of elements: \a group1 [0,4] and \a group2 [ 0,1,2 ],
+ * then there are 3 families:
+ * - \a family1 (with ID 1) contains element [0] belonging to ( \a group1 + \a group2 ),
+ * - \a family2 (with ID 2) contains elements [4] belonging to ( \a group1 ),
+ * - \a family3 (with ID 3) contains element [1,2] belonging to ( \a group2 ), <br>
+ * and the result array contains IDs of families [ 1,3,3,0,2 ]. <br> Note a family ID 0 which
+ * stands for the element #3 which is in none of groups.
*
- * @param groups in arrays specifying ids of each groups.
- * @param newNb specifies size of whole set. Must be at least equal to max eltid in 'groups'.
- * @return an array of size newNb specifying fid of each item.
+ * \param [in] groups - sequence of groups of element IDs.
+ * \param [in] newNb - total number of elements; it must be more than max ID of element
+ * in \a groups.
+ * \param [out] fidsOfGroups - IDs of families the elements of each group belong to.
+ * \return DataArrayInt * - a new instance of DataArrayInt containing IDs of families
+ * each element with ID from range [0, \a newNb ) belongs to. The caller is to
+ * delete this array using decrRef() as it is no more needed.
+ * \throw If any element ID in \a groups violates condition ( 0 <= ID < \a newNb ).
*/
DataArrayInt *DataArrayInt::MakePartition(const std::vector<const DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups) throw(INTERP_KERNEL::Exception)
{
return ret.retn();
}
+/*!
+ * Returns a new DataArrayInt which contains all elements of given one-dimensional
+ * not negative arrays. The result array does not contain any duplicates and its values
+ * are sorted in ascending order.
+ * \param [in] arr - sequence of DataArrayInt's to unite.
+ * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
+ * array using decrRef() as it is no more needed.
+ * \throw If any \a arr[i] is not allocated.
+ * \throw If \a arr[i]->getNumberOfComponents() != 1.
+ * \throw If any value of \a arr[i] is negative.
+ */
DataArrayInt *DataArrayInt::BuildUnion(const std::vector<const DataArrayInt *>& arr) throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayInt *> a;
return ret;
}
+/*!
+ * Returns a new DataArrayInt which contains elements present in each of given one-dimensional
+ * not negative arrays. The result array does not contain any duplicates and its values
+ * are sorted in ascending order.
+ * \param [in] arr - sequence of DataArrayInt's to intersect.
+ * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
+ * array using decrRef() as it is no more needed.
+ * \throw If any \a arr[i] is not allocated.
+ * \throw If \a arr[i]->getNumberOfComponents() != 1.
+ * \throw If any value of \a arr[i] < 0.
+ */
DataArrayInt *DataArrayInt::BuildIntersection(const std::vector<const DataArrayInt *>& arr) throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayInt *> a;
return ret;
}
+/*!
+ * Returns a new DataArrayInt which contains a complement of elements of \a this
+ * one-dimensional array. I.e. the result array contains all elements from the range [0,
+ * \a nbOfElement) not present in \a this array.
+ * \param [in] nbOfElement - maximal size of the result array.
+ * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
+ * array using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If any element \a x of \a this array violates condition ( 0 <= \a x < \a
+ * nbOfElement ).
+ */
DataArrayInt *DataArrayInt::buildComplement(int nbOfElement) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
}
/*!
- * \sa DataArrayInt::buildSubstractionOptimized
+ * Returns a new DataArrayInt containing elements of \a this one-dimensional missing
+ * from an \a other one-dimensional array.
+ * \param [in] other - a DataArrayInt containing elements not to include in the result array.
+ * \return DataArrayInt * - a new instance of DataArrayInt with one component. The
+ * caller is to delete this array using decrRef() as it is no more needed.
+ * \throw If \a other is NULL.
+ * \throw If \a other is not allocated.
+ * \throw If \a other->getNumberOfComponents() != 1.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \sa DataArrayInt::buildSubstractionOptimized()
*/
DataArrayInt *DataArrayInt::buildSubstraction(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
{
return ret.retn();
}
+
+/*!
+ * Returns a new DataArrayInt which contains all elements of \a this and a given
+ * one-dimensional not negative arrays. The result array does not contain any duplicates
+ * and its values are sorted in ascending order.
+ * \param [in] other - an array to unite with \a this one.
+ * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
+ * array using decrRef() as it is no more needed.
+ * \throw If \a this or \a other is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If \a other->getNumberOfComponents() != 1.
+ * \throw If any value of \a this or \a other is negative.
+ */
DataArrayInt *DataArrayInt::buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayInt *>arrs(2);
return BuildUnion(arrs);
}
+
+/*!
+ * Returns a new DataArrayInt which contains elements present in both \a this and a given
+ * one-dimensional not negative arrays. The result array does not contain any duplicates
+ * and its values are sorted in ascending order.
+ * \param [in] other - an array to intersect with \a this one.
+ * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
+ * array using decrRef() as it is no more needed.
+ * \throw If \a this or \a other is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If \a other->getNumberOfComponents() != 1.
+ * \throw If any value of \a this or \a other is negative.
+ */
DataArrayInt *DataArrayInt::buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayInt *>arrs(2);
}
/*!
- * This method could be usefull for returned DataArrayInt marked as index. Some methods that generate such DataArrayInt instances:
- * - ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity
- * - ParaMEDMEM::MEDCouplingUMesh::getNodalConnectivityIndex
- * This method makes the assumption that 'this' is allocated and has exactly one component and 2 or more tuples. If not an exception is thrown.
- * This method retrives a newly created DataArrayInt instance with 1 component and this->getNumberOfTuples()-1 tuples.
- * If this contains [1,3,6,7,7,9,15] -> returned array will contain [2,3,1,0,2,6].
+ * Returns a new DataArrayInt which contains size of every of groups described by \a this
+ * "index" array. Such "index" array is returned for example by
+ * \ref ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity
+ * "MEDCouplingUMesh::buildDescendingConnectivity" and
+ * \ref ParaMEDMEM::MEDCouplingUMesh::getNodalConnectivityIndex
+ * "MEDCouplingUMesh::getNodalConnectivityIndex" etc.
+ * \return DataArrayInt * - a new instance of DataArrayInt, whose number of tuples
+ * equals to \a this->getNumberOfComponents() - 1, and number of components is 1.
+ * The caller is to delete this array using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If \a this->getNumberOfTuples() < 2.
+ *
+ * \b Example: <br>
+ * - this contains [1,3,6,7,7,9,15]
+ * - result array contains [2,3,1,0,2,6],
+ * where 2 = 3 - 1, 3 = 6 - 3, 1 = 7 - 6 etc.
*/
DataArrayInt *DataArrayInt::deltaShiftIndex() const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method performs the work on itself. This method works on array with number of component equal to one and allocated. If not an exception is thrown.
- * This method conserves the number of tuples and number of components (1). No reallocation is done.
- * For an array [3,5,1,2,0,8] it becomes [0,3,8,9,11,11]. For each i>0 new[i]=new[i-1]+old[i-1] for i==0 new[i]=0.
- * This could be usefull for allToAllV in MPI with contiguous policy.
+ * Modifies \a this one-dimensional array so that value of each element \a x
+ * of \a this array (\a a) is computed as \f$ x_i = \sum_{j=0}^{i-1} a[ j ] \f$.
+ * Or: for each i>0 new[i]=new[i-1]+old[i-1] for i==0 new[i]=0. Number of tuples
+ * and components remains the same.<br>
+ * This method is useful for allToAllV in MPI with contiguous policy. This method
+ * differs from computeOffsets2() in that the number of tuples is \b not changed by
+ * this one.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ *
+ * \b Example: <br>
+ * - Before \a this contains [3,5,1,2,0,8]
+ * - After \a this contains [0,3,8,9,11,11]<br>
+ * Note that the last element 19 = 11 + 8 is missing because size of \a this
+ * array is retained and thus there is no space to store the last element.
*/
void DataArrayInt::computeOffsets() throw(INTERP_KERNEL::Exception)
{
declareAsNew();
}
+
/*!
- * Idem DataArrayInt::computeOffsets method execpt that 'this' changes its number of tuples.
- * After the call in case of success new number of tuples is equal to old number of tuples +1.
- * The content in 'this' for the first old number of tuples is exactly the same than those given by
- * DataArrayInt::computeOffsets method.
- * For an array [3,5,1,2,0,8] it becomes [0,3,8,9,11,11,19].
+ * Modifies \a this one-dimensional array so that value of each element \a x
+ * of \a this array (\a a) is computed as \f$ x_i = \sum_{j=0}^{i-1} a[ j ] \f$.
+ * Or: for each i>0 new[i]=new[i-1]+old[i-1] for i==0 new[i]=0. Number
+ * components remains the same and number of tuples is inceamented by one.<br>
+ * This method is useful for allToAllV in MPI with contiguous policy. This method
+ * differs from computeOffsets() in that the number of tuples is changed by this one.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ *
+ * \b Example: <br>
+ * - Before \a this contains [3,5,1,2,0,8]
+ * - After \a this contains [0,3,8,9,11,11,19]<br>
*/
void DataArrayInt::computeOffsets2() throw(INTERP_KERNEL::Exception)
{
declareAsNew();
}
+
/*!
- * This method works on array with number of component equal to one and allocated. If not an exception is thrown.
- * 'offsets' should be monotic ascendently. If not, an exception will be thrown.
- * This method retrives a newly created DataArrayInt instance with 1 component and this->getNumberOfTuples()-1 tuples.
- * If 'this' contains [0,2,3] and 'offsets' [0,3,6,10,14,20] the returned array will contain [0,1,2,6,7,8,9,10,11,12,13]
+ * Returns a new DataArrayInt whose contents is computed from that of \a this and \a
+ * offsets arrays as follows. \a offsets is a one-dimensional array considered as an
+ * "index" array of a "iota" array, thus, whose each element gives an index of a group
+ * beginning within the "iota" array. And \a this is a one-dimensional array
+ * considered as a selector of groups described by \a offsets to include into the result array.
+ * \throw If \a offsets is NULL.
+ * \throw If \a offsets is not allocated.
+ * \throw If \a offsets->getNumberOfComponents() != 1.
+ * \throw If \a offsets is not monotonically increasing.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 1.
+ * \throw If any element of \a this is not a valid index for \a offsets array.
+ *
+ * \b Example: <br>
+ * - \a this: [0,2,3]
+ * - \a offsets: [0,3,6,10,14,20]
+ * - result array: [0,1,2,6,7,8,9,10,11,12,13] == <br>
+ * \c range(0,3) + \c range(6,10) + \c range(10,14) ==<br>
+ * \c range( \a offsets[ \a this[0] ], offsets[ \a this[0]+1 ]) +
+ * \c range( \a offsets[ \a this[1] ], offsets[ \a this[1]+1 ]) +
+ * \c range( \a offsets[ \a this[2] ], offsets[ \a this[2]+1 ])
*/
DataArrayInt *DataArrayInt::buildExplicitArrByRanges(const DataArrayInt *offsets) const throw(INTERP_KERNEL::Exception)
{
/*!
* This method returns all different values found in \a this. This method throws if \a this has not been allocated.
* But the number of components can be different from one.
+ * \return a newly allocated array (that should be dealt by the caller) containing different values in \a this.
*/
-std::set<int> DataArrayInt::getDifferentValues() const throw(INTERP_KERNEL::Exception)
+DataArrayInt *DataArrayInt::getDifferentValues() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
std::set<int> ret;
ret.insert(begin(),end());
- return ret;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret2=DataArrayInt::New(); ret2->alloc((int)ret.size(),1);
+ std::copy(ret.begin(),ret.end(),ret2->getPointer());
+ return ret2.retn();
}
/*!
return ret;
}
+/*!
+ * Returns a new DataArrayInt that is a sum of two given arrays. There are 3
+ * valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * the result array (_a_) is a sum of the corresponding values of \a a1 and \a a2,
+ * i.e.: _a_ [ i, j ] = _a1_ [ i, j ] + _a2_ [ i, j ].
+ * 2. The arrays have same number of tuples and one array, say _a2_, has one
+ * component. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] + _a2_ [ i, 0 ].
+ * 3. The arrays have same number of components and one array, say _a2_, has one
+ * tuple. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] + _a2_ [ 0, j ].
+ *
+ * Info on components is copied either from the first array (in the first case) or from
+ * the array with maximal number of elements (getNbOfElems()).
+ * \param [in] a1 - an array to sum up.
+ * \param [in] a2 - another array to sum up.
+ * \return DataArrayInt * - the new instance of DataArrayInt.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If either \a a1 or \a a2 is NULL.
+ * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples() and
+ * \a a1->getNumberOfComponents() != \a a2->getNumberOfComponents() and
+ * none of them has number of tuples or components equal to 1.
+ */
DataArrayInt *DataArrayInt::Add(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception)
{
if(!a1 || !a2)
return ret.retn();
}
+/*!
+ * Adds values of another DataArrayInt to values of \a this one. There are 3
+ * valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * \a other array is added to the corresponding value of \a this array, i.e.:
+ * _a_ [ i, j ] += _other_ [ i, j ].
+ * 2. The arrays have same number of tuples and \a other array has one component. Then
+ * _a_ [ i, j ] += _other_ [ i, 0 ].
+ * 3. The arrays have same number of components and \a other array has one tuple. Then
+ * _a_ [ i, j ] += _a2_ [ 0, j ].
+ *
+ * \param [in] other - an array to add to \a this one.
+ * \throw If \a other is NULL.
+ * \throw If \a this->getNumberOfTuples() != \a other->getNumberOfTuples() and
+ * \a this->getNumberOfComponents() != \a other->getNumberOfComponents() and
+ * \a other has number of both tuples and components not equal to 1.
+ */
void DataArrayInt::addEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception)
{
if(!other)
declareAsNew();
}
+/*!
+ * Returns a new DataArrayInt that is a subtraction of two given arrays. There are 3
+ * valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * the result array (_a_) is a subtraction of the corresponding values of \a a1 and
+ * \a a2, i.e.: _a_ [ i, j ] = _a1_ [ i, j ] - _a2_ [ i, j ].
+ * 2. The arrays have same number of tuples and one array, say _a2_, has one
+ * component. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] - _a2_ [ i, 0 ].
+ * 3. The arrays have same number of components and one array, say _a2_, has one
+ * tuple. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] - _a2_ [ 0, j ].
+ *
+ * Info on components is copied either from the first array (in the first case) or from
+ * the array with maximal number of elements (getNbOfElems()).
+ * \param [in] a1 - an array to subtract from.
+ * \param [in] a2 - an array to subtract.
+ * \return DataArrayInt * - the new instance of DataArrayInt.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If either \a a1 or \a a2 is NULL.
+ * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples() and
+ * \a a1->getNumberOfComponents() != \a a2->getNumberOfComponents() and
+ * none of them has number of tuples or components equal to 1.
+ */
DataArrayInt *DataArrayInt::Substract(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception)
{
if(!a1 || !a2)
}
}
+/*!
+ * Subtract values of another DataArrayInt from values of \a this one. There are 3
+ * valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * \a other array is subtracted from the corresponding value of \a this array, i.e.:
+ * _a_ [ i, j ] -= _other_ [ i, j ].
+ * 2. The arrays have same number of tuples and \a other array has one component. Then
+ * _a_ [ i, j ] -= _other_ [ i, 0 ].
+ * 3. The arrays have same number of components and \a other array has one tuple. Then
+ * _a_ [ i, j ] -= _a2_ [ 0, j ].
+ *
+ * \param [in] other - an array to subtract from \a this one.
+ * \throw If \a other is NULL.
+ * \throw If \a this->getNumberOfTuples() != \a other->getNumberOfTuples() and
+ * \a this->getNumberOfComponents() != \a other->getNumberOfComponents() and
+ * \a other has number of both tuples and components not equal to 1.
+ */
void DataArrayInt::substractEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception)
{
if(!other)
declareAsNew();
}
+/*!
+ * Returns a new DataArrayInt that is a product of two given arrays. There are 3
+ * valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * the result array (_a_) is a product of the corresponding values of \a a1 and
+ * \a a2, i.e.: _a_ [ i, j ] = _a1_ [ i, j ] * _a2_ [ i, j ].
+ * 2. The arrays have same number of tuples and one array, say _a2_, has one
+ * component. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] * _a2_ [ i, 0 ].
+ * 3. The arrays have same number of components and one array, say _a2_, has one
+ * tuple. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] * _a2_ [ 0, j ].
+ *
+ * Info on components is copied either from the first array (in the first case) or from
+ * the array with maximal number of elements (getNbOfElems()).
+ * \param [in] a1 - a factor array.
+ * \param [in] a2 - another factor array.
+ * \return DataArrayInt * - the new instance of DataArrayInt.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If either \a a1 or \a a2 is NULL.
+ * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples() and
+ * \a a1->getNumberOfComponents() != \a a2->getNumberOfComponents() and
+ * none of them has number of tuples or components equal to 1.
+ */
DataArrayInt *DataArrayInt::Multiply(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception)
{
if(!a1 || !a2)
return ret.retn();
}
+
+/*!
+ * Multiply values of another DataArrayInt to values of \a this one. There are 3
+ * valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * \a other array is multiplied to the corresponding value of \a this array, i.e.:
+ * _a_ [ i, j ] *= _other_ [ i, j ].
+ * 2. The arrays have same number of tuples and \a other array has one component. Then
+ * _a_ [ i, j ] *= _other_ [ i, 0 ].
+ * 3. The arrays have same number of components and \a other array has one tuple. Then
+ * _a_ [ i, j ] *= _a2_ [ 0, j ].
+ *
+ * \param [in] other - an array to multiply to \a this one.
+ * \throw If \a other is NULL.
+ * \throw If \a this->getNumberOfTuples() != \a other->getNumberOfTuples() and
+ * \a this->getNumberOfComponents() != \a other->getNumberOfComponents() and
+ * \a other has number of both tuples and components not equal to 1.
+ */
void DataArrayInt::multiplyEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception)
{
if(!other)
declareAsNew();
}
+
+/*!
+ * Returns a new DataArrayInt that is a division of two given arrays. There are 3
+ * valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * the result array (_a_) is a division of the corresponding values of \a a1 and
+ * \a a2, i.e.: _a_ [ i, j ] = _a1_ [ i, j ] / _a2_ [ i, j ].
+ * 2. The arrays have same number of tuples and one array, say _a2_, has one
+ * component. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] / _a2_ [ i, 0 ].
+ * 3. The arrays have same number of components and one array, say _a2_, has one
+ * tuple. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] / _a2_ [ 0, j ].
+ *
+ * Info on components is copied either from the first array (in the first case) or from
+ * the array with maximal number of elements (getNbOfElems()).
+ * \param [in] a1 - a numerator array.
+ * \param [in] a2 - a denominator array.
+ * \return DataArrayInt * - the new instance of DataArrayInt.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If either \a a1 or \a a2 is NULL.
+ * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples() and
+ * \a a1->getNumberOfComponents() != \a a2->getNumberOfComponents() and
+ * none of them has number of tuples or components equal to 1.
+ * \warning No check of division by zero is performed!
+ */
DataArrayInt *DataArrayInt::Divide(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception)
{
if(!a1 || !a2)
}
}
+/*!
+ * Divide values of \a this array by values of another DataArrayInt. There are 3
+ * valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * \a this array is divided by the corresponding value of \a other one, i.e.:
+ * _a_ [ i, j ] /= _other_ [ i, j ].
+ * 2. The arrays have same number of tuples and \a other array has one component. Then
+ * _a_ [ i, j ] /= _other_ [ i, 0 ].
+ * 3. The arrays have same number of components and \a other array has one tuple. Then
+ * _a_ [ i, j ] /= _a2_ [ 0, j ].
+ *
+ * \param [in] other - an array to divide \a this one by.
+ * \throw If \a other is NULL.
+ * \throw If \a this->getNumberOfTuples() != \a other->getNumberOfTuples() and
+ * \a this->getNumberOfComponents() != \a other->getNumberOfComponents() and
+ * \a other has number of both tuples and components not equal to 1.
+ * \warning No check of division by zero is performed!
+ */
void DataArrayInt::divideEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception)
{
if(!other)
declareAsNew();
}
+
+/*!
+ * Returns a new DataArrayInt that is a modulus of two given arrays. There are 3
+ * valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * the result array (_a_) is a division of the corresponding values of \a a1 and
+ * \a a2, i.e.: _a_ [ i, j ] = _a1_ [ i, j ] % _a2_ [ i, j ].
+ * 2. The arrays have same number of tuples and one array, say _a2_, has one
+ * component. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] % _a2_ [ i, 0 ].
+ * 3. The arrays have same number of components and one array, say _a2_, has one
+ * tuple. Then
+ * _a_ [ i, j ] = _a1_ [ i, j ] % _a2_ [ 0, j ].
+ *
+ * Info on components is copied either from the first array (in the first case) or from
+ * the array with maximal number of elements (getNbOfElems()).
+ * \param [in] a1 - a dividend array.
+ * \param [in] a2 - a divisor array.
+ * \return DataArrayInt * - the new instance of DataArrayInt.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If either \a a1 or \a a2 is NULL.
+ * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples() and
+ * \a a1->getNumberOfComponents() != \a a2->getNumberOfComponents() and
+ * none of them has number of tuples or components equal to 1.
+ * \warning No check of division by zero is performed!
+ */
DataArrayInt *DataArrayInt::Modulus(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception)
{
if(!a1 || !a2)
}
}
+/*!
+ * Modify \a this array so that each value becomes a modulus of division of this value by
+ * a value of another DataArrayInt. There are 3 valid cases.
+ * 1. The arrays have same number of tuples and components. Then each value of
+ * \a this array is divided by the corresponding value of \a other one, i.e.:
+ * _a_ [ i, j ] %= _other_ [ i, j ].
+ * 2. The arrays have same number of tuples and \a other array has one component. Then
+ * _a_ [ i, j ] %= _other_ [ i, 0 ].
+ * 3. The arrays have same number of components and \a other array has one tuple. Then
+ * _a_ [ i, j ] %= _a2_ [ 0, j ].
+ *
+ * \param [in] other - a divisor array.
+ * \throw If \a other is NULL.
+ * \throw If \a this->getNumberOfTuples() != \a other->getNumberOfTuples() and
+ * \a this->getNumberOfComponents() != \a other->getNumberOfComponents() and
+ * \a other has number of both tuples and components not equal to 1.
+ * \warning No check of division by zero is performed!
+ */
void DataArrayInt::modulusEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception)
{
if(!other)
declareAsNew();
}
+/*!
+ * Returns a C array which is a renumbering map in "Old to New" mode for the input array.
+ * This map, if applied to \a start array, would make it sorted. For example, if
+ * \a start array contents are [9,10,0,6,4,11,3,7] then the contents of the result array is
+ * [5,6,0,3,2,7,1,4].
+ * \param [in] start - pointer to the first element of the array for which the
+ * permutation map is computed.
+ * \param [in] end - pointer specifying the end of the array \a start, so that
+ * the last value of \a start is \a end[ -1 ].
+ * \return int * - the result permutation array that the caller is to delete as it is no
+ * more needed.
+ * \throw If there are equal values in the input array.
+ */
int *DataArrayInt::CheckAndPreparePermutation(const int *start, const int *end)
{
std::size_t sz=std::distance(start,end);
return ret;
}
+/*!
+ * Returns a new DataArrayInt containing an arithmetic progression
+ * that is equal to the sequence returned by Python \c range(\a begin,\a end,\a step )
+ * function.
+ * \param [in] begin - the start value of the result sequence.
+ * \param [in] end - limiting value, so that every value of the result array is less than
+ * \a end.
+ * \param [in] step - specifies the increment or decrement.
+ * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
+ * array using decrRef() as it is no more needed.
+ * \throw If \a step == 0.
+ * \throw If \a end < \a begin && \a step > 0.
+ * \throw If \a end > \a begin && \a step < 0.
+ */
DataArrayInt *DataArrayInt::Range(int begin, int end, int step) throw(INTERP_KERNEL::Exception)
{
int nbOfTuples=GetNumberOfItemGivenBESRelative(begin,end,step,"DataArrayInt::Range");
#include "MEDCouplingTimeLabel.hxx"
#include "MEDCouplingRefCountObject.hxx"
#include "InterpKernelException.hxx"
+#include "BBTreePts.txx"
#include "BBTree.txx"
-#include <set>
#include <string>
#include <vector>
#include <iterator>
MEDCOUPLING_EXPORT bool isEqual(const DataArrayDouble& other, double prec) const;
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayDouble& other, double prec, std::string& reason) const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const;
- //!alloc or useArray should have been called before.
MEDCOUPLING_EXPORT void reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *convertToIntArr() const;
MEDCOUPLING_EXPORT DataArrayDouble *fromNoInterlace() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void findCommonTuples(double prec, int limitTupleId, DataArrayInt *&comm, DataArrayInt *&commIndex) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT double minimalDistanceTo(const DataArrayDouble *other, int& thisTupleId, int& otherTupleId) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *duplicateEachTupleNTimes(int nbTimes) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *getDifferentValues(double prec, int limitTupleId=-1) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *findClosestTupleId(const DataArrayDouble *other) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayDouble *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValues1(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValuesSimple1(double a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void multiplyEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT static DataArrayDouble *Divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void divideEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
- //! nothing to do here because this class does not aggregate any TimeLabel instance.
MEDCOUPLING_EXPORT void updateTime() const { }
public:
MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
template<int SPACEDIM>
void findCommonTuplesAlg(const double *bbox, int nbNodes, int limitNodeId, double prec, DataArrayInt *c, DataArrayInt *cI) const;
template<int SPACEDIM>
+ static void FindClosestTupleIdAlg(const BBTreePts<SPACEDIM,int>& myTree, double dist, const double *pos, int nbOfTuples, const double *thisPt, int thisNbOfTuples, int *res);
+ template<int SPACEDIM>
static void FindTupleIdsNearTuplesAlg(const BBTree<SPACEDIM,int>& myTree, const double *pos, int nbOfTuples, double eps,
DataArrayInt *c, DataArrayInt *cI);
private:
MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const;
MEDCOUPLING_EXPORT DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const;
MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2OBis(int newNbOfElem) const throw(INTERP_KERNEL::Exception);
- //!alloc or useArray should have been called before.
MEDCOUPLING_EXPORT void reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *convertToDblArr() const;
MEDCOUPLING_EXPORT DataArrayInt *fromNoInterlace() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *findRangeIdForEachTuple(const DataArrayInt *ranges) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *findIdInRangeForEachTuple(const DataArrayInt *ranges) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *duplicateEachTupleNTimes(int nbTimes) const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT std::set<int> getDifferentValues() const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *getDifferentValues() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT std::vector<DataArrayInt *> partitionByDifferentValues(std::vector<int>& differentIds) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
void MEDCOUPLING_EXPORT useExternalArrayWithRWAccess(const int *array, int nbOfTuple, int nbOfCompo);
MEDCOUPLING_EXPORT void divideEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT static DataArrayInt *Modulus(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void modulusEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
- //! nothing to do here because this class does not aggregate any TimeLabel instance.
MEDCOUPLING_EXPORT void updateTime() const { }
public:
MEDCOUPLING_EXPORT static int *CheckAndPreparePermutation(const int *start, const int *end);
* This method checks geo equivalence between two meshes : 'this' and 'other'.
* If no exception is throw 'this' and 'other' are geometrically equivalent regarding 'levOfCheck' level.
* This method is typically used to change the mesh of a field "safely" depending the 'levOfCheck' level considered.
+ * So in case of success cell \c other[i] is equal to cell \c this[cellCor[i]]. If \a cellCor is null it means that for all i cell \c other[i] is equal to cell \c this[i].
*
* @param levOfCheck input that specifies the level of check specified. The possible values are listed below.
* @param prec input that specifies precision for double float data used for comparison in meshes.
{
if((const MEDCouplingFieldDouble *)other._fs[i])
{
- MEDCouplingFieldTemplate *tmp=MEDCouplingFieldTemplate::New(other._fs[i]);
- _fs[i]=MEDCouplingFieldDouble::New(tmp,other._fs[i]->getTimeDiscretization());
+ MEDCouplingFieldTemplate *tmp=MEDCouplingFieldTemplate::New(*other._fs[i]);
+ _fs[i]=MEDCouplingFieldDouble::New(*tmp,other._fs[i]->getTimeDiscretization());
tmp->decrRef();
if(refs[i]!=-1)
_fs[i]->setMesh(ms2[refs[i]]);
int offD=0;
for(int i=0;i<sz;i++)
{
- _fs[i]=MEDCouplingFieldDouble::New(ft[i],(TypeOfTimeDiscretization)tinyInfoI[2*sz+3+i]);
+ _fs[i]=MEDCouplingFieldDouble::New(*ft[i],(TypeOfTimeDiscretization)tinyInfoI[2*sz+3+i]);
int sz3=tinyInfoI[sz+i+3];
std::vector<DataArrayDouble *> tmp(sz3);
for(int j=0;j<sz3;j++,k++)
typedef int MyConnType;
static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_C_MODE;
public:
- MEDCouplingNormalizedCartesianMesh(ParaMEDMEM::MEDCouplingCMesh *mesh);
+ MEDCouplingNormalizedCartesianMesh(const ParaMEDMEM::MEDCouplingCMesh *mesh);
//void getBoundingBox(double *boundingBox) const;
//INTERP_KERNEL::NormalizedCellType getTypeOfElement(int eltId) const;
//unsigned char getNumberOfNodesOfElement(int eltId) const;
const double * getCoordsAlongAxis(int axis) const;
~MEDCouplingNormalizedCartesianMesh();
private:
- ParaMEDMEM::MEDCouplingCMesh *_mesh;
+ const ParaMEDMEM::MEDCouplingCMesh *_mesh;
};
#endif
#include "MEDCouplingCMesh.hxx"
template<int SPACEDIM>
-MEDCouplingNormalizedCartesianMesh<SPACEDIM>::MEDCouplingNormalizedCartesianMesh(ParaMEDMEM::MEDCouplingCMesh *mesh):_mesh(mesh)
+MEDCouplingNormalizedCartesianMesh<SPACEDIM>::MEDCouplingNormalizedCartesianMesh(const ParaMEDMEM::MEDCouplingCMesh *mesh):_mesh(mesh)
{
if(_mesh)
_mesh->incrRef();
*/
void MEDCouplingPointSet::translate(const double *vector)
{
+ if(!vector)
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::translate : NULL input vector !");
+ if(!_coords)
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::translate : no coordinates set !");
double *coords=_coords->getPointer();
int nbNodes=getNumberOfNodes();
int dim=getSpaceDimension();
*/
void MEDCouplingPointSet::scale(const double *point, double factor)
{
+ if(!point)
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::scale : NULL input point !");
+ if(!_coords)
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::scale : no coordinates set !");
double *coords=_coords->getPointer();
int nbNodes=getNumberOfNodes();
int dim=getSpaceDimension();
double matrix[9];
double matrixTmp[9];
double norm=sqrt(vect[0]*vect[0]+vect[1]*vect[1]+vect[2]*vect[2]);
+ if(norm<std::numeric_limits<double>::min())
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::Rotate3DAlg : magnitude of input vector is too close of 0. !");
std::transform(vect,vect+3,vectorNorm,std::bind2nd(std::multiplies<double>(),1/norm));
//rotation matrix computation
matrix[0]=cosa; matrix[1]=0.; matrix[2]=0.; matrix[3]=0.; matrix[4]=cosa; matrix[5]=0.; matrix[6]=0.; matrix[7]=0.; matrix[8]=cosa;
* This method build a part of 'this' by simply keeping cells whose ids are in ['start','end') \b and potentially reduces the nodes set
* behind returned mesh. This cause an overhead but it is lesser in memory.
* This method returns an array too. This array allows to the caller to know the mapping between nodeids in 'this' and nodeids in
- * returned mesh. This is quite usefull for MEDCouplingFieldDouble on nodes for example...
+ * returned mesh. This is quite useful for MEDCouplingFieldDouble on nodes for example...
* 'arr' is in old2New format of size ret->getNumberOfCells like MEDCouplingUMesh::zipCoordsTraducer is.
* The returned mesh has to be managed by the caller.
*/
using namespace ParaMEDMEM;
-MEDCouplingRemapper::MEDCouplingRemapper():_src_mesh(0),_target_mesh(0),_nature_of_deno(NoNature),_time_deno_update(0)
+MEDCouplingRemapper::MEDCouplingRemapper():_src_ft(0),_target_ft(0),_interp_matrix_pol(IK_ONLY_PREFERED),_nature_of_deno(NoNature),_time_deno_update(0)
{
}
int MEDCouplingRemapper::prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const char *method) throw(INTERP_KERNEL::Exception)
{
+ if(!srcMesh || !targetMesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepare : presence of NULL input pointer !");
+ std::string srcMethod,targetMethod;
+ INTERP_KERNEL::Interpolation<INTERP_KERNEL::Interpolation3D>::CheckAndSplitInterpolationMethod(method,srcMethod,targetMethod);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldTemplate> src=MEDCouplingFieldTemplate::New(MEDCouplingFieldDiscretization::GetTypeOfFieldFromStringRepr(srcMethod.c_str()));
+ src->setMesh(srcMesh);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldTemplate> target=MEDCouplingFieldTemplate::New(MEDCouplingFieldDiscretization::GetTypeOfFieldFromStringRepr(targetMethod.c_str()));
+ target->setMesh(targetMesh);
+ return prepareEx(src,target);
+}
+
+int MEDCouplingRemapper::prepareEx(const MEDCouplingFieldTemplate *src, const MEDCouplingFieldTemplate *target) throw(INTERP_KERNEL::Exception)
+{
+ if(!src || !target)
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareEx : presence of NULL input pointer !");
+ if(!src->getMesh() || !target->getMesh())
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareEx : presence of NULL mesh pointer in given field template !");
releaseData(true);
- _src_mesh=const_cast<MEDCouplingMesh *>(srcMesh); _target_mesh=const_cast<MEDCouplingMesh *>(targetMesh);
- _src_mesh->incrRef(); _target_mesh->incrRef();
- int meshInterpType=((int)_src_mesh->getType()*16)+(int)_target_mesh->getType();
+ _src_ft=const_cast<MEDCouplingFieldTemplate *>(src); _src_ft->incrRef();
+ _target_ft=const_cast<MEDCouplingFieldTemplate *>(target); _target_ft->incrRef();
+ if(isInterpKernelOnlyOrNotOnly())
+ return prepareInterpKernelOnly();
+ else
+ return prepareNotInterpKernelOnly();
+}
+
+int MEDCouplingRemapper::prepareInterpKernelOnly() throw(INTERP_KERNEL::Exception)
+{
+ int meshInterpType=((int)_src_ft->getMesh()->getType()*16)+(int)_target_ft->getMesh()->getType();
switch(meshInterpType)
{
case 85://Unstructured-Unstructured
- return prepareUU(method);
+ return prepareInterpKernelOnlyUU();
case 87://Unstructured-Cartesian
- return prepareUC(method);
+ return prepareInterpKernelOnlyUC();
case 117://Cartesian-Unstructured
- return prepareCU(method);
+ return prepareInterpKernelOnlyCU();
case 119://Cartesian-Cartesian
- return prepareCC(method);
+ return prepareInterpKernelOnlyCC();
case 136://Extruded-Extruded
- return prepareEE(method);
+ return prepareInterpKernelOnlyEE();
default:
- throw INTERP_KERNEL::Exception("Not managed type of meshes !");
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnly : Not managed type of meshes ! Dealt meshes type are : Unstructured<->Unstructured, Unstructured<->Cartesian, Cartesian<->Cartesian, Extruded<->Extruded !");
}
}
-int MEDCouplingRemapper::prepareEx(const MEDCouplingFieldTemplate *src, const MEDCouplingFieldTemplate *target) throw(INTERP_KERNEL::Exception)
+int MEDCouplingRemapper::prepareNotInterpKernelOnly() throw(INTERP_KERNEL::Exception)
{
- std::string meth(src->getDiscretization()->getStringRepr());
- meth+=target->getDiscretization()->getStringRepr();
- return prepare(src->getMesh(),target->getMesh(),meth.c_str());
+ std::string srcm,trgm,method;
+ method=checkAndGiveInterpolationMethodStr(srcm,trgm);
+ switch(CheckInterpolationMethodManageableByNotOnlyInterpKernel(method))
+ {
+ case 0:
+ return prepareNotInterpKernelOnlyGaussGauss();
+ default:
+ {
+ std::ostringstream oss; oss << "MEDCouplingRemapper::prepareNotInterpKernelOnly : INTERNAL ERROR ! the method \"" << method << "\" declared as managed bu not implemented !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
}
/*!
void MEDCouplingRemapper::reverseTransfer(MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception)
{
- if(_src_method!=srcField->getDiscretization()->getStringRepr())
+ checkPrepare();
+ if(_src_ft->getDiscretization()->getStringRepr()!=srcField->getDiscretization()->getStringRepr())
throw INTERP_KERNEL::Exception("Incoherency with prepare call for source field");
- if(_target_method!=targetField->getDiscretization()->getStringRepr())
+ if(_target_ft->getDiscretization()->getStringRepr()!=targetField->getDiscretization()->getStringRepr())
throw INTERP_KERNEL::Exception("Incoherency with prepare call for target field");
if(srcField->getNature()!=targetField->getNature())
throw INTERP_KERNEL::Exception("Natures of fields mismatch !");
MEDCouplingFieldDouble *MEDCouplingRemapper::transferField(const MEDCouplingFieldDouble *srcField, double dftValue) throw(INTERP_KERNEL::Exception)
{
- if(_src_method!=srcField->getDiscretization()->getStringRepr())
+ checkPrepare();
+ if(_src_ft->getDiscretization()->getStringRepr()!=srcField->getDiscretization()->getStringRepr())
throw INTERP_KERNEL::Exception("Incoherency with prepare call for source field");
- MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(MEDCouplingFieldDiscretization::getTypeOfFieldFromStringRepr(_target_method.c_str()),srcField->getTimeDiscretization());
- ret->copyAllTinyAttrFrom(srcField);
+ MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(*_target_ft,srcField->getTimeDiscretization());
ret->setNature(srcField->getNature());
- ret->setMesh(_target_mesh);
transfer(srcField,ret,dftValue);
+ ret->copyAllTinyAttrFrom(srcField);//perform copy of tiny strings after and not before transfer because the array will be created on transfer
return ret;
}
MEDCouplingFieldDouble *MEDCouplingRemapper::reverseTransferField(const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception)
{
- if(_target_method!=targetField->getDiscretization()->getStringRepr())
+ checkPrepare();
+ if(_target_ft->getDiscretization()->getStringRepr()!=targetField->getDiscretization()->getStringRepr())
throw INTERP_KERNEL::Exception("Incoherency with prepare call for target field");
- MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(MEDCouplingFieldDiscretization::getTypeOfFieldFromStringRepr(_src_method.c_str()),targetField->getTimeDiscretization());
- ret->copyAllTinyAttrFrom(targetField);
+ MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(*_src_ft,targetField->getTimeDiscretization());
ret->setNature(targetField->getNature());
- ret->setMesh(_src_mesh);
reverseTransfer(ret,targetField,dftValue);
+ ret->copyAllTinyAttrFrom(targetField);//perform copy of tiny strings after and not before reverseTransfer because the array will be created on reverseTransfer
return ret;
}
+/*!
+ * This method does nothing more than inherited INTERP_KERNEL::InterpolationOptions::setOptionInt method. This method
+ * is here only for automatic CORBA generators.
+ */
bool MEDCouplingRemapper::setOptionInt(const std::string& key, int value)
{
return INTERP_KERNEL::InterpolationOptions::setOptionInt(key,value);
}
+/*!
+ * This method does nothing more than inherited INTERP_KERNEL::InterpolationOptions::setOptionInt method. This method
+ * is here only for automatic CORBA generators.
+ */
bool MEDCouplingRemapper::setOptionDouble(const std::string& key, double value)
{
return INTERP_KERNEL::InterpolationOptions::setOptionDouble(key,value);
}
+/*!
+ * This method does nothing more than inherited INTERP_KERNEL::InterpolationOptions::setOptionInt method. This method
+ * is here only for automatic CORBA generators.
+ */
bool MEDCouplingRemapper::setOptionString(const std::string& key, const std::string& value)
{
return INTERP_KERNEL::InterpolationOptions::setOptionString(key,value);
}
-int MEDCouplingRemapper::prepareUU(const char *method) throw(INTERP_KERNEL::Exception)
+/*!
+ * This method returns the interpolation matrix policy. This policy specifies which interpolation matrix method to keep or prefered.
+ * If interpolation matrix policy is :
+ *
+ * - set to IK_ONLY_PREFERED (0) (the default) : the INTERP_KERNEL only method is prefered. That is to say, if it is possible to treat the case
+ * regarding spatial discretization of source and target with INTERP_KERNEL only method, INTERP_KERNEL only method will be performed.
+ * If not, the \b not only INTERP_KERNEL method will be attempt.
+ *
+ * - set to NOT_IK_ONLY_PREFERED (1) : the \b NOT only INTERP_KERNEL method is prefered. That is to say, if it is possible to treat the case
+ * regarding spatial discretization of source and target with \b NOT only INTERP_KERNEL method, \b NOT only INTERP_KERNEL method, will be performed.
+ * If not, the INTERP_KERNEL only method will be attempt.
+ *
+ * - IK_ONLY_FORCED (2) : Only INTERP_KERNEL only method will be launched.
+ *
+ * - NOT_IK_ONLY_FORCED (3) : Only \b NOT INTERP_KERNEL only method will be launched.
+ *
+ * \sa MEDCouplingRemapper::setInterpolationMatrixPolicy
+ */
+int MEDCouplingRemapper::getInterpolationMatrixPolicy() const
+{
+ return _interp_matrix_pol;
+}
+
+/*!
+ * This method sets a new interpolation matrix policy. The default one is IK_PREFERED (0). The input is of type \c int to be dealt by standard Salome
+ * CORBA component generators. This method throws an INTERP_KERNEL::Exception if a the input integer is not in the available possibilities, that is to say not in
+ * [0 (IK_PREFERED) , 1 (NOT_IK_PREFERED), 2 (IK_ONLY_FORCED), 3 (NOT_IK_ONLY_FORCED)].
+ *
+ * If interpolation matrix policy is :
+ *
+ * - set to IK_ONLY_PREFERED (0) (the default) : the INTERP_KERNEL only method is prefered. That is to say, if it is possible to treat the case
+ * regarding spatial discretization of source and target with INTERP_KERNEL only method, INTERP_KERNEL only method will be performed.
+ * If not, the \b not only INTERP_KERNEL method will be attempt.
+ *
+ * - set to NOT_IK_ONLY_PREFERED (1) : the \b NOT only INTERP_KERNEL method is prefered. That is to say, if it is possible to treat the case
+ * regarding spatial discretization of source and target with \b NOT only INTERP_KERNEL method, \b NOT only INTERP_KERNEL method, will be performed.
+ * If not, the INTERP_KERNEL only method will be attempt.
+ *
+ * - IK_ONLY_FORCED (2) : Only INTERP_KERNEL only method will be launched.
+ *
+ * - NOT_IK_ONLY_FORCED (3) : Only \b NOT INTERP_KERNEL only method will be launched.
+ *
+ * \input newInterpMatPol the new interpolation matrix method policy. This parameter is of type \c int and not of type \c ParaMEDMEM::InterpolationMatrixPolicy
+ * for automatic generation of CORBA component.
+ *
+ * \sa MEDCouplingRemapper::getInterpolationMatrixPolicy
+ */
+void MEDCouplingRemapper::setInterpolationMatrixPolicy(int newInterpMatPol) throw(INTERP_KERNEL::Exception)
+{
+ switch(newInterpMatPol)
+ {
+ case 0:
+ _interp_matrix_pol=IK_ONLY_PREFERED;
+ break;
+ case 1:
+ _interp_matrix_pol=NOT_IK_ONLY_PREFERED;
+ break;
+ case 2:
+ _interp_matrix_pol=IK_ONLY_FORCED;
+ break;
+ case 3:
+ _interp_matrix_pol=NOT_IK_ONLY_FORCED;
+ break;
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::setInterpolationMatrixPolicy : invalid input integer value ! Should be in [0 (IK_PREFERED) , 1 (NOT_IK_PREFERED), 2 (IK_ONLY_FORCED), 3 (NOT_IK_ONLY_FORCED)] ! For information, the default is IK_PREFERED=0 !");
+ }
+}
+
+int MEDCouplingRemapper::prepareInterpKernelOnlyUU() throw(INTERP_KERNEL::Exception)
{
- MEDCouplingUMesh *src_mesh=(MEDCouplingUMesh *)_src_mesh;
- MEDCouplingUMesh *target_mesh=(MEDCouplingUMesh *)_target_mesh;
- INTERP_KERNEL::Interpolation<INTERP_KERNEL::Interpolation3D>::checkAndSplitInterpolationMethod(method,_src_method,_target_method);
+ const MEDCouplingUMesh *src_mesh=static_cast<const MEDCouplingUMesh *>(_src_ft->getMesh());
+ const MEDCouplingUMesh *target_mesh=static_cast<const MEDCouplingUMesh *>(_target_ft->getMesh());
+ std::string srcMeth,trgMeth;
+ std::string method=checkAndGiveInterpolationMethodStr(srcMeth,trgMeth);
const int srcMeshDim=src_mesh->getMeshDimension();
int srcSpaceDim=-1;
if(srcMeshDim!=-1)
MEDCouplingNormalizedUnstructuredMesh<1,1> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<1,1> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation1D interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
}
else if(srcMeshDim==1 && trgMeshDim==1 && srcSpaceDim==2)
{
MEDCouplingNormalizedUnstructuredMesh<2,1> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<2,1> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2DCurve interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
}
else if(srcMeshDim==2 && trgMeshDim==2 && srcSpaceDim==2)
{
MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2D interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
}
else if(srcMeshDim==3 && trgMeshDim==3 && srcSpaceDim==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3D interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
}
else if(srcMeshDim==2 && trgMeshDim==2 && srcSpaceDim==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<3,2> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3DSurf interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
}
else if(srcMeshDim==3 && trgMeshDim==1 && srcSpaceDim==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3D interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
}
else if(srcMeshDim==1 && trgMeshDim==3 && srcSpaceDim==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3D interpolation(*this);
std::vector<std::map<int,double> > matrixTmp;
- nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method);
+ nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method.c_str());
ReverseMatrix(matrixTmp,nbCols,_matrix);
nbCols=matrixTmp.size();
}
MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2D interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
}
else
{
MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2D1D interpolation(*this);
std::vector<std::map<int,double> > matrixTmp;
- nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method);
+ nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method.c_str());
ReverseMatrix(matrixTmp,nbCols,_matrix);
nbCols=matrixTmp.size();
INTERP_KERNEL::Interpolation2D1D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces();
MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2D interpolation(*this);
std::vector<std::map<int,double> > matrixTmp;
- nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method);
+ nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method.c_str());
ReverseMatrix(matrixTmp,nbCols,_matrix);
nbCols=matrixTmp.size();
}
MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2D1D interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
INTERP_KERNEL::Interpolation2D1D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces();
if(!duplicateFaces.empty())
{
MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3D2D interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces();
if(!duplicateFaces.empty())
{
MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3D2D interpolation(*this);
std::vector<std::map<int,double> > matrixTmp;
- nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method);
+ nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method.c_str());
ReverseMatrix(matrixTmp,nbCols,_matrix);
nbCols=matrixTmp.size();
INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces();
{
MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(src_mesh);
INTERP_KERNEL::Interpolation2D interpolation(*this);
- nbCols=interpolation.toIntegralUniform(source_mesh_wrapper,_matrix,_src_method.c_str());
+ nbCols=interpolation.toIntegralUniform(source_mesh_wrapper,_matrix,srcMeth.c_str());
}
else if(srcMeshDim==3 && srcSpaceDim==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh);
INTERP_KERNEL::Interpolation3D interpolation(*this);
- nbCols=interpolation.toIntegralUniform(source_mesh_wrapper,_matrix,_src_method.c_str());
+ nbCols=interpolation.toIntegralUniform(source_mesh_wrapper,_matrix,srcMeth.c_str());
}
else if(srcMeshDim==2 && srcSpaceDim==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(src_mesh);
INTERP_KERNEL::Interpolation3DSurf interpolation(*this);
- nbCols=interpolation.toIntegralUniform(source_mesh_wrapper,_matrix,_src_method.c_str());
+ nbCols=interpolation.toIntegralUniform(source_mesh_wrapper,_matrix,srcMeth.c_str());
}
else
throw INTERP_KERNEL::Exception("No interpolation available for the given mesh and space dimension of source mesh to -1D targetMesh");
{
MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2D interpolation(*this);
- nbCols=interpolation.fromIntegralUniform(source_mesh_wrapper,_matrix,_target_method.c_str());
+ nbCols=interpolation.fromIntegralUniform(source_mesh_wrapper,_matrix,trgMeth.c_str());
}
else if(trgMeshDim==3 && trgSpaceDim==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3D interpolation(*this);
- nbCols=interpolation.fromIntegralUniform(source_mesh_wrapper,_matrix,_target_method.c_str());
+ nbCols=interpolation.fromIntegralUniform(source_mesh_wrapper,_matrix,trgMeth.c_str());
}
else if(trgMeshDim==2 && trgSpaceDim==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3DSurf interpolation(*this);
- nbCols=interpolation.fromIntegralUniform(source_mesh_wrapper,_matrix,_target_method.c_str());
+ nbCols=interpolation.fromIntegralUniform(source_mesh_wrapper,_matrix,trgMeth.c_str());
}
else
throw INTERP_KERNEL::Exception("No interpolation available for the given mesh and space dimension of source mesh from -1D sourceMesh");
return 1;
}
-int MEDCouplingRemapper::prepareEE(const char *method) throw(INTERP_KERNEL::Exception)
+int MEDCouplingRemapper::prepareInterpKernelOnlyEE() throw(INTERP_KERNEL::Exception)
{
- MEDCouplingExtrudedMesh *src_mesh=(MEDCouplingExtrudedMesh *)_src_mesh;
- MEDCouplingExtrudedMesh *target_mesh=(MEDCouplingExtrudedMesh *)_target_mesh;
- std::string methC(method);
+ std::string srcMeth,trgMeth;
+ std::string methC=checkAndGiveInterpolationMethodStr(srcMeth,trgMeth);
+ const MEDCouplingExtrudedMesh *src_mesh=static_cast<const MEDCouplingExtrudedMesh *>(_src_ft->getMesh());
+ const MEDCouplingExtrudedMesh *target_mesh=static_cast<const MEDCouplingExtrudedMesh *>(_target_ft->getMesh());
if(methC!="P0P0")
- throw INTERP_KERNEL::Exception("Only P0P0 method implemented for Extruded/Extruded meshes !");
- INTERP_KERNEL::Interpolation<INTERP_KERNEL::Interpolation3D>::checkAndSplitInterpolationMethod(method,_src_method,_target_method);
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyEE : Only P0P0 method implemented for Extruded/Extruded meshes !");
MEDCouplingNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(src_mesh->getMesh2D());
MEDCouplingNormalizedUnstructuredMesh<3,2> target_mesh_wrapper(target_mesh->getMesh2D());
INTERP_KERNEL::Interpolation3DSurf interpolation2D(*this);
std::vector<std::map<int,double> > matrix2D;
- int nbCols2D=interpolation2D.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,matrix2D,method);
+ int nbCols2D=interpolation2D.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,matrix2D,methC.c_str());
MEDCouplingUMesh *s1D,*t1D;
double v[3];
MEDCouplingExtrudedMesh::Project1DMeshes(src_mesh->getMesh1D(),target_mesh->getMesh1D(),getPrecision(),s1D,t1D,v);
MEDCouplingNormalizedUnstructuredMesh<1,1> t1DWrapper(t1D);
std::vector<std::map<int,double> > matrix1D;
INTERP_KERNEL::Interpolation1D interpolation1D(*this);
- int nbCols1D=interpolation1D.interpolateMeshes(s1DWrapper,t1DWrapper,matrix1D,method);
+ int nbCols1D=interpolation1D.interpolateMeshes(s1DWrapper,t1DWrapper,matrix1D,methC.c_str());
s1D->decrRef();
t1D->decrRef();
buildFinalInterpolationMatrixByConvolution(matrix1D,matrix2D,src_mesh->getMesh3DIds()->getConstPointer(),nbCols2D,nbCols1D,
return 1;
}
-int MEDCouplingRemapper::prepareUC(const char *method) throw(INTERP_KERNEL::Exception)
+int MEDCouplingRemapper::prepareInterpKernelOnlyUC() throw(INTERP_KERNEL::Exception)
{
- std::string methodCpp(method);
+ std::string srcMeth,trgMeth;
+ std::string methodCpp=checkAndGiveInterpolationMethodStr(srcMeth,trgMeth);
if(methodCpp!="P0P0")
- throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareUC : only P0P0 interpolation supported for the moment !");
- INTERP_KERNEL::Interpolation<INTERP_KERNEL::Interpolation3D>::checkAndSplitInterpolationMethod(method,_src_method,_target_method);
- MEDCouplingUMesh *src_mesh=static_cast<MEDCouplingUMesh *>(_src_mesh);
- MEDCouplingCMesh *target_mesh=static_cast<MEDCouplingCMesh *>(_target_mesh);
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyUC : only P0P0 interpolation supported for the moment !");
+ const MEDCouplingUMesh *src_mesh=static_cast<const MEDCouplingUMesh *>(_src_ft->getMesh());
+ const MEDCouplingCMesh *target_mesh=static_cast<const MEDCouplingCMesh *>(_target_ft->getMesh());
const int srcMeshDim=src_mesh->getMeshDimension();
const int srcSpceDim=src_mesh->getSpaceDimension();
const int trgMeshDim=target_mesh->getMeshDimension();
if(srcMeshDim!=srcSpceDim || srcMeshDim!=trgMeshDim)
- throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareUC : space dim of src unstructured should be equal to mesh dim of src unstructured and should be equal also equal to trg cartesian dimension !");
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyUC : space dim of src unstructured should be equal to mesh dim of src unstructured and should be equal also equal to trg cartesian dimension !");
std::vector<std::map<int,double> > res;
switch(srcMeshDim)
{
break;
}
default:
- throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareUC : only dimension 1 2 or 3 supported !");
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyUC : only dimension 1 2 or 3 supported !");
}
ReverseMatrix(res,target_mesh->getNumberOfCells(),_matrix);
nullifiedTinyCoeffInCrudeMatrixAbs(0.);
return 1;
}
-int MEDCouplingRemapper::prepareCU(const char *method) throw(INTERP_KERNEL::Exception)
+int MEDCouplingRemapper::prepareInterpKernelOnlyCU() throw(INTERP_KERNEL::Exception)
{
- std::string methodCpp(method);
+ std::string srcMeth,trgMeth;
+ std::string methodCpp=checkAndGiveInterpolationMethodStr(srcMeth,trgMeth);
if(methodCpp!="P0P0")
- throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareCU : only P0P0 interpolation supported for the moment !");
- INTERP_KERNEL::Interpolation<INTERP_KERNEL::Interpolation3D>::checkAndSplitInterpolationMethod(method,_src_method,_target_method);
- MEDCouplingCMesh *src_mesh=static_cast<MEDCouplingCMesh *>(_src_mesh);
- MEDCouplingUMesh *target_mesh=static_cast<MEDCouplingUMesh *>(_target_mesh);
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyCU : only P0P0 interpolation supported for the moment !");
+ const MEDCouplingCMesh *src_mesh=static_cast<const MEDCouplingCMesh *>(_src_ft->getMesh());
+ const MEDCouplingUMesh *target_mesh=static_cast<const MEDCouplingUMesh *>(_target_ft->getMesh());
const int srcMeshDim=src_mesh->getMeshDimension();
const int trgMeshDim=target_mesh->getMeshDimension();
const int trgSpceDim=target_mesh->getSpaceDimension();
if(trgMeshDim!=trgSpceDim || trgMeshDim!=srcMeshDim)
- throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareCU : space dim of target unstructured should be equal to mesh dim of target unstructured and should be equal also equal to source cartesian dimension !");
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyCU : space dim of target unstructured should be equal to mesh dim of target unstructured and should be equal also equal to source cartesian dimension !");
switch(srcMeshDim)
{
case 1:
break;
}
default:
- throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareCU : only dimension 1 2 or 3 supported !");
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyCU : only dimension 1 2 or 3 supported !");
}
nullifiedTinyCoeffInCrudeMatrixAbs(0.);
//
return 1;
}
-int MEDCouplingRemapper::prepareCC(const char *method) throw(INTERP_KERNEL::Exception)
+int MEDCouplingRemapper::prepareInterpKernelOnlyCC() throw(INTERP_KERNEL::Exception)
{
- std::string methodCpp(method);
+ std::string srcMeth,trgMeth;
+ std::string methodCpp=checkAndGiveInterpolationMethodStr(srcMeth,trgMeth);
if(methodCpp!="P0P0")
- throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareCC : only P0P0 interpolation supported for the moment !");
- INTERP_KERNEL::Interpolation<INTERP_KERNEL::Interpolation3D>::checkAndSplitInterpolationMethod(method,_src_method,_target_method);
- MEDCouplingCMesh *src_mesh=static_cast<MEDCouplingCMesh *>(_src_mesh);
- MEDCouplingCMesh *target_mesh=static_cast<MEDCouplingCMesh *>(_target_mesh);
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyCC : only P0P0 interpolation supported for the moment !");
+ const MEDCouplingCMesh *src_mesh=static_cast<const MEDCouplingCMesh *>(_src_ft->getMesh());
+ const MEDCouplingCMesh *target_mesh=static_cast<const MEDCouplingCMesh *>(_target_ft->getMesh());
const int srcMeshDim=src_mesh->getMeshDimension();
const int trgMeshDim=target_mesh->getMeshDimension();
if(trgMeshDim!=srcMeshDim)
- throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareCC : dim of target cartesian should be equal to dim of source cartesian dimension !");
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyCC : dim of target cartesian should be equal to dim of source cartesian dimension !");
switch(srcMeshDim)
{
case 1:
break;
}
default:
- throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareCC : only dimension 1 2 or 3 supported !");
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyCC : only dimension 1 2 or 3 supported !");
}
nullifiedTinyCoeffInCrudeMatrixAbs(0.);
//
return 1;
}
+int MEDCouplingRemapper::prepareNotInterpKernelOnlyGaussGauss() throw(INTERP_KERNEL::Exception)
+{
+ if(getIntersectionType()!=INTERP_KERNEL::PointLocator)
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareNotInterpKernelOnlyGaussGauss : The intersection type is not supported ! Only PointLocator is supported for Gauss->Gauss interpolation ! Please invoke setIntersectionType(PointLocator) on the MEDCouplingRemapper instance !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> trgLoc=_target_ft->getLocalizationOfDiscr();
+ const double *trgLocPtr=trgLoc->begin();
+ int trgSpaceDim=trgLoc->getNumberOfComponents();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> srcOffsetArr=_src_ft->getDiscretization()->getOffsetArr(_src_ft->getMesh());
+ if(trgSpaceDim!=_src_ft->getMesh()->getSpaceDimension())
+ {
+ std::ostringstream oss; oss << "MEDCouplingRemapper::prepareNotInterpKernelOnlyGaussGauss : space dimensions mismatch between source and target !";
+ oss << " Target discretization localization has dimension " << trgSpaceDim << ", whereas the space dimension of source is equal to ";
+ oss << _src_ft->getMesh()->getSpaceDimension() << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ const int *srcOffsetArrPtr=srcOffsetArr->begin();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> srcLoc=_src_ft->getLocalizationOfDiscr();
+ const double *srcLocPtr=srcLoc->begin();
+ std::vector<int> elts,eltsIndex;
+ int trgNbOfGaussPts=trgLoc->getNumberOfTuples();
+ _matrix.resize(trgNbOfGaussPts);
+ _src_ft->getMesh()->getCellsContainingPoints(trgLoc->begin(),trgNbOfGaussPts,getPrecision(),elts,eltsIndex);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> eltsIndex2=DataArrayInt::New(); eltsIndex2->useArray(&eltsIndex[0],false,CPP_DEALLOC,(int)eltsIndex.size(),1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nbOfSrcCellsShTrgPts=eltsIndex2->deltaShiftIndex();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids0=nbOfSrcCellsShTrgPts->getIdsNotEqual(0);
+ for(const int *trgId=ids0->begin();trgId!=ids0->end();trgId++)
+ {
+ const double *ptTrg=trgLocPtr+trgSpaceDim*(*trgId);
+ int srcCellId=elts[eltsIndex[*trgId]];
+ double dist=std::numeric_limits<double>::max();
+ int srcEntry=-1;
+ for(int srcId=srcOffsetArrPtr[srcCellId];srcId<srcOffsetArrPtr[srcCellId+1];srcId++)
+ {
+ const double *ptSrc=srcLocPtr+trgSpaceDim*srcId;
+ double tmp=0.;
+ for(int i=0;i<trgSpaceDim;i++)
+ tmp+=(ptTrg[i]-ptSrc[i])*(ptTrg[i]-ptSrc[i]);
+ if(tmp<dist)
+ { dist=tmp; srcEntry=srcId; }
+ }
+ _matrix[*trgId][srcEntry]=1.;
+ }
+ if(ids0->getNumberOfTuples()!=trgNbOfGaussPts)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> orphanTrgIds=nbOfSrcCellsShTrgPts->getIdsEqual(0);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> orphanTrg=trgLoc->selectByTupleId(orphanTrgIds->begin(),orphanTrgIds->end());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> srcIdPerTrg=srcLoc->findClosestTupleId(orphanTrg);
+ const int *srcIdPerTrgPtr=srcIdPerTrg->begin();
+ for(const int *orphanTrgId=orphanTrgIds->begin();orphanTrgId!=orphanTrgIds->end();orphanTrgId++,srcIdPerTrgPtr++)
+ _matrix[*orphanTrgId][*srcIdPerTrgPtr]=2.;
+ }
+ _deno_multiply.clear();
+ _deno_multiply.resize(_matrix.size());
+ _deno_reverse_multiply.clear();
+ _deno_reverse_multiply.resize(srcLoc->getNumberOfTuples());
+ declareAsNew();
+ return 1;
+}
+
+/*!
+ * This method checks that the input interpolation \a method is managed by not INTERP_KERNEL only methods.
+ * If no an INTERP_KERNEL::Exception will be thrown. If yes, a magic number will be returned to switch in the MEDCouplingRemapper::prepareNotInterpKernelOnly method.
+ */
+int MEDCouplingRemapper::CheckInterpolationMethodManageableByNotOnlyInterpKernel(const std::string& method) throw(INTERP_KERNEL::Exception)
+{
+ if(method=="GAUSSGAUSS")
+ return 0;
+ std::ostringstream oss; oss << "MEDCouplingRemapper::CheckInterpolationMethodManageableByNotOnlyInterpKernel : ";
+ oss << "The method \"" << method << "\" is not manageable by not INTERP_KERNEL only method.";
+ oss << " Not only INTERP_KERNEL methods dealed are : GAUSSGAUSS !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+/*!
+ * This method determines regarding \c _interp_matrix_pol attribute ( set by MEDCouplingRemapper::setInterpolationMatrixPolicy and by default equal
+ * to IK_ONLY_PREFERED = 0 ) , which method will be applied. If \c true is returned the INTERP_KERNEL only method should be applied to \c false the \b not
+ * only INTERP_KERNEL method should be applied.
+ */
+bool MEDCouplingRemapper::isInterpKernelOnlyOrNotOnly() const throw(INTERP_KERNEL::Exception)
+{
+ std::string srcm,trgm,method;
+ method=checkAndGiveInterpolationMethodStr(srcm,trgm);
+ switch(_interp_matrix_pol)
+ {
+ case IK_ONLY_PREFERED:
+ {
+ try
+ {
+ std::string tmp1,tmp2;
+ INTERP_KERNEL::Interpolation<INTERP_KERNEL::Interpolation3D>::CheckAndSplitInterpolationMethod(method.c_str(),tmp1,tmp2);
+ return true;
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ {
+ return false;
+ }
+ }
+ case NOT_IK_ONLY_PREFERED:
+ {
+ try
+ {
+ CheckInterpolationMethodManageableByNotOnlyInterpKernel(method);
+ return false;
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ {
+ return true;
+ }
+ }
+ case IK_ONLY_FORCED:
+ return true;
+ case NOT_IK_ONLY_FORCED:
+ return false;
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::isInterpKernelOnlyOrNotOnly : internal error ! The interpolation matrix policy is not managed ! Try to change it using MEDCouplingRemapper::setInterpolationMatrixPolicy !");
+ }
+}
+
void MEDCouplingRemapper::updateTime() const
{
}
+void MEDCouplingRemapper::checkPrepare() const throw(INTERP_KERNEL::Exception)
+{
+ const MEDCouplingFieldTemplate *s(_src_ft),*t(_target_ft);
+ if(!s || !t)
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::checkPrepare : it appears that MEDCouplingRemapper::prepare(Ex) has not been called !");
+ if(!s->getMesh() || !t->getMesh())
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::checkPrepare : it appears that no all field templates have their mesh set !");
+}
+
+/*!
+ * This method builds a code considering already set field discretization int \a this : \a _src_ft and \a _target_ft.
+ * This method returns 3 informations (2 in ouput parameters and 1 in return).
+ *
+ * \param [out] srcMeth the string code of the discretization of source field template
+ * \param [out] trgMeth the string code of the discretization of target field template
+ * \return the standardized string code (compatible with INTERP_KERNEL) for matrix of numerators (in \a _matrix)
+ */
+std::string MEDCouplingRemapper::checkAndGiveInterpolationMethodStr(std::string& srcMeth, std::string& trgMeth) const throw(INTERP_KERNEL::Exception)
+{
+ const MEDCouplingFieldTemplate *s(_src_ft),*t(_target_ft);
+ if(!s || !t)
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::checkAndGiveInterpolationMethodStr : it appears that no all field templates have been set !");
+ if(!s->getMesh() || !t->getMesh())
+ throw INTERP_KERNEL::Exception("MEDCouplingRemapper::checkAndGiveInterpolationMethodStr : it appears that no all field templates have their mesh set !");
+ srcMeth=_src_ft->getDiscretization()->getRepr();
+ trgMeth=_target_ft->getDiscretization()->getRepr();
+ std::string method(srcMeth); method+=trgMeth;
+ return method;
+}
+
void MEDCouplingRemapper::releaseData(bool matrixSuppression)
{
- if(_src_mesh)
- _src_mesh->decrRef();
- if(_target_mesh)
- _target_mesh->decrRef();
- _src_mesh=0;
- _target_mesh=0;
+ _src_ft=0;
+ _target_ft=0;
if(matrixSuppression)
{
_matrix.clear();
void MEDCouplingRemapper::transferUnderground(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, bool isDftVal, double dftValue) throw(INTERP_KERNEL::Exception)
{
- if(_src_method!=srcField->getDiscretization()->getStringRepr())
+ checkPrepare();
+ if(_src_ft->getDiscretization()->getStringRepr()!=srcField->getDiscretization()->getStringRepr())
throw INTERP_KERNEL::Exception("Incoherency with prepare call for source field");
- if(_target_method!=targetField->getDiscretization()->getStringRepr())
+ if(_target_ft->getDiscretization()->getStringRepr()!=targetField->getDiscretization()->getStringRepr())
throw INTERP_KERNEL::Exception("Incoherency with prepare call for target field");
if(srcField->getNature()!=targetField->getNature())
throw INTERP_KERNEL::Exception("Natures of fields mismatch !");
#include "MEDCouplingTimeLabel.hxx"
#include "InterpolationOptions.hxx"
#include "MEDCouplingNatureOfField.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
#include "InterpKernelException.hxx"
#include <map>
namespace ParaMEDMEM
{
class MEDCouplingMesh;
- class MEDCouplingUMesh;
class MEDCouplingFieldDouble;
class MEDCouplingFieldTemplate;
}
namespace ParaMEDMEM
{
+ typedef enum
+ {
+ IK_ONLY_PREFERED = 0,
+ NOT_IK_ONLY_PREFERED = 1,
+ IK_ONLY_FORCED = 2,
+ NOT_IK_ONLY_FORCED =3
+ } InterpolationMatrixPolicy;
+
class MEDCouplingRemapper : public TimeLabel, public INTERP_KERNEL::InterpolationOptions
{
public:
MEDCOUPLINGREMAPPER_EXPORT bool setOptionInt(const std::string& key, int value);
MEDCOUPLINGREMAPPER_EXPORT bool setOptionDouble(const std::string& key, double value);
MEDCOUPLINGREMAPPER_EXPORT bool setOptionString(const std::string& key, const std::string& value);
+ MEDCOUPLINGREMAPPER_EXPORT int getInterpolationMatrixPolicy() const;
+ MEDCOUPLINGREMAPPER_EXPORT void setInterpolationMatrixPolicy(int newInterpMatPol) throw(INTERP_KERNEL::Exception);
//
MEDCOUPLINGREMAPPER_EXPORT int nullifiedTinyCoeffInCrudeMatrixAbs(double maxValAbs) throw(INTERP_KERNEL::Exception);
MEDCOUPLINGREMAPPER_EXPORT int nullifiedTinyCoeffInCrudeMatrix(double scaleFactor) throw(INTERP_KERNEL::Exception);
MEDCOUPLINGREMAPPER_EXPORT const std::vector<std::map<int,double> >& getCrudeMatrix() const;
MEDCOUPLINGREMAPPER_EXPORT static void PrintMatrix(const std::vector<std::map<int,double> >& m);
private:
- int prepareUU(const char *method) throw(INTERP_KERNEL::Exception);
- int prepareEE(const char *method) throw(INTERP_KERNEL::Exception);
- int prepareUC(const char *method) throw(INTERP_KERNEL::Exception);
- int prepareCU(const char *method) throw(INTERP_KERNEL::Exception);
- int prepareCC(const char *method) throw(INTERP_KERNEL::Exception);
+ int prepareInterpKernelOnly() throw(INTERP_KERNEL::Exception);
+ int prepareInterpKernelOnlyUU() throw(INTERP_KERNEL::Exception);
+ int prepareInterpKernelOnlyEE() throw(INTERP_KERNEL::Exception);
+ int prepareInterpKernelOnlyUC() throw(INTERP_KERNEL::Exception);
+ int prepareInterpKernelOnlyCU() throw(INTERP_KERNEL::Exception);
+ int prepareInterpKernelOnlyCC() throw(INTERP_KERNEL::Exception);
+ //
+ int prepareNotInterpKernelOnly() throw(INTERP_KERNEL::Exception);
+ int prepareNotInterpKernelOnlyGaussGauss() throw(INTERP_KERNEL::Exception);
+ //
+ static int CheckInterpolationMethodManageableByNotOnlyInterpKernel(const std::string& method) throw(INTERP_KERNEL::Exception);
+ //
+ bool isInterpKernelOnlyOrNotOnly() const throw(INTERP_KERNEL::Exception);
void updateTime() const;
+ void checkPrepare() const throw(INTERP_KERNEL::Exception);
+ std::string checkAndGiveInterpolationMethodStr(std::string& srcMeth, std::string& trgMeth) const throw(INTERP_KERNEL::Exception);
void releaseData(bool matrixSuppression);
void transferUnderground(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, bool isDftVal, double dftValue) throw(INTERP_KERNEL::Exception);
void computeDeno(NatureOfField nat, const MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *trgField);
static void ComputeColSumAndRowSum(const std::vector<std::map<int,double> >& matrixDeno,
std::vector<std::map<int,double> >& deno, std::vector<std::map<int,double> >& denoReverse);
private:
- MEDCouplingMesh *_src_mesh;
- MEDCouplingMesh *_target_mesh;
- std::string _src_method;
- std::string _target_method;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldTemplate> _src_ft;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldTemplate> _target_ft;
+ InterpolationMatrixPolicy _interp_matrix_pol;
NatureOfField _nature_of_deno;
unsigned int _time_deno_update;
std::vector<std::map<int,double> > _matrix;
if(_time<other._time)
_time=other._time;
}
+
+/*!
+ * This method has to be called with a lot of care. It set agressively the time in this with the
+ * time in \a other.
+ */
+void TimeLabel::forceTimeOfThis(const TimeLabel& other) const
+{
+ _time=other._time;
+}
TimeLabel();
virtual ~TimeLabel();
void updateTimeWith(const TimeLabel& other) const;
+ void forceTimeOfThis(const TimeLabel& other) const;
private:
static unsigned int GLOBAL_TIME;
mutable unsigned int _time;
const INTERP_KERNEL::CellModel& _cm;
};
+class MinusOneSonsGeneratorBiQuadratic
+{
+public:
+ MinusOneSonsGeneratorBiQuadratic(const INTERP_KERNEL::CellModel& cm):_cm(cm) { }
+ unsigned getNumberOfSons2(const int *conn, int lgth) const { return _cm.getNumberOfSons2(conn,lgth); }
+ unsigned fillSonCellNodalConnectivity2(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, INTERP_KERNEL::NormalizedCellType& typeOfSon) const { return _cm.fillSonCellNodalConnectivity4(sonId,nodalConn,lgth,sonNodalConn,typeOfSon); }
+ static const int DELTA=1;
+private:
+ const INTERP_KERNEL::CellModel& _cm;
+};
+
class MinusTwoSonsGenerator
{
public:
template<class SonsGenerator>
MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivityGen(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx, DimM1DescNbrer nbrer) const throw(INTERP_KERNEL::Exception)
{
+ if(!desc || !descIndx || !revDesc || !revDescIndx)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildDescendingConnectivityGen : present of a null pointer in input !");
checkConnectivityFullyDefined();
int nbOfCells=getNumberOfCells();
int nbOfNodes=getNumberOfNodes();
* When called 'this' is an invalid mesh on MED sense. This method will correct that for polyhedra.
* In case of presence of polyhedron that has not the extruded aspect (2 faces with the same number of nodes) an exception is thrown and 'this'
* remains unchanged.
- * This method is usefull only for users that wants to build extruded unstructured mesh.
+ * This method is useful only for users that wants to build extruded unstructured mesh.
* This method is a convenient one that avoids boring polyhedra setting during insertNextCell process.
* In case of success, 'this' has be corrected contains the same number of cells and is valid in MED sense.
*/
const int *conn=_nodal_connec->getConstPointer();
const int *connIndex=_nodal_connec_index->getConstPointer();
int nbOfElem=_nodal_connec_index->getNbOfElems()-1;
- for(const int *pt=connIndex;pt!=connIndex+nbOfElem;pt++)
- _types.insert((INTERP_KERNEL::NormalizedCellType)conn[*pt]);
+ if (nbOfElem > 0)
+ for(const int *pt=connIndex;pt !=connIndex+nbOfElem;pt++)
+ _types.insert((INTERP_KERNEL::NormalizedCellType)conn[*pt]);
}
}
}
/*!
- * This methods returns a field on nodes and no time. This method is usefull to check "P1*" conservative interpolators.
+ * This methods returns a field on nodes and no time. This method is useful to check "P1*" conservative interpolators.
* This field returns the getMeasureField of the dualMesh in P1 sens of 'this'.
*/
MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureFieldOnNode(bool isAbs) const
case 1:
ret=convertLinearCellsToQuadratic1D0(conn,connI,coords,types);
connSafe=conn; connISafe=connI; coordsSafe=coords;
- break;
+ break;
case 2:
ret=convertLinearCellsToQuadratic2D0(conn,connI,coords,types);
connSafe=conn; connISafe=connI; coordsSafe=coords;
- break;
+ break;
case 3:
ret=convertLinearCellsToQuadratic3D0(conn,connI,coords,types);
connSafe=conn; connISafe=connI; coordsSafe=coords;
- break;
+ break;
default:
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertLinearCellsToQuadratic : conversion of type 0 mesh dimensions available are [1,2,3] !");
}
break;
- //case 1:
- //return convertLinearCellsToQuadratic1();
+ case 1:
+ {
+ switch(meshDim)
+ {
+ case 1:
+ ret=convertLinearCellsToQuadratic1D0(conn,connI,coords,types);//it is not a bug. In 1D policy 0 and 1 are equals
+ connSafe=conn; connISafe=connI; coordsSafe=coords;
+ break;
+ case 2:
+ ret=convertLinearCellsToQuadratic2D1(conn,connI,coords,types);
+ connSafe=conn; connISafe=connI; coordsSafe=coords;
+ break;
+ case 3:
+ ret=convertLinearCellsToQuadratic3D1(conn,connI,coords,types);
+ connSafe=conn; connISafe=connI; coordsSafe=coords;
+ break;
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertLinearCellsToQuadratic : conversion of type 1 mesh dimensions available are [1,2,3] !");
+ }
+ break;
+ }
default:
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertLinearCellsToQuadratic : conversion type available are 0 (default, the simplest) and 1 (the most complex) !");
}
newConn->pushBackSilent((int)INTERP_KERNEL::NORM_SEG3);
newConn->pushBackValsSilent(cPtr+icPtr[0]+1,cPtr+icPtr[0]+3);
newConn->pushBackSilent(offset++);
- lastVal+=4;
+ lastVal+=4;
newConnI->pushBackSilent(lastVal);
ret->pushBackSilent(i);
}
}
}
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp=bary->selectByTupleIdSafe(ret->begin(),ret->end());
- conn=newConn.retn(); connI=newConnI.retn(); coords=DataArrayDouble::Aggregate(getCoords(),tmp);
+ coords=DataArrayDouble::Aggregate(getCoords(),tmp); conn=newConn.retn(); connI=newConnI.retn();
return ret.retn();
}
newConn->pushBackValsSilent(cPtr+icPtr[0]+1,cPtr+icPtr[1]);
for(const int *d=descPtr+descIPtr[0];d!=descPtr+descIPtr[1];d++)
newConn->pushBackSilent(c1DPtr[c1DIPtr[*d]+3]);
- lastVal+=(icPtr[1]-icPtr[0])+(descIPtr[1]-descIPtr[0]);
- newConnI->pushBackSilent(lastVal);
+ lastVal+=(icPtr[1]-icPtr[0])+(descIPtr[1]-descIPtr[0]);
+ newConnI->pushBackSilent(lastVal);
ret->pushBackSilent(i);
}
else
return convertLinearCellsToQuadratic2DAnd3D0(m1D,desc,descI,conn,connI,coords,types);
}
+DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic2D1(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> desc(DataArrayInt::New()),descI(DataArrayInt::New()),tmp2(DataArrayInt::New()),tmp3(DataArrayInt::New());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m1D=buildDescendingConnectivity(desc,descI,tmp2,tmp3); tmp2=0; tmp3=0;
+ //
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConn=DataArrayInt::New(); newConn->alloc(0,1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConnI=DataArrayInt::New(); newConnI->alloc(1,1); newConnI->setIJ(0,0,0);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New(); ret->alloc(0,1);
+ //
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> bary=getBarycenterAndOwner();
+ const int *descPtr(desc->begin()),*descIPtr(descI->begin());
+ DataArrayInt *conn1D=0,*conn1DI=0;
+ std::set<INTERP_KERNEL::NormalizedCellType> types1D;
+ DataArrayDouble *coordsTmp=0;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret1D=m1D->convertLinearCellsToQuadratic1D0(conn1D,conn1DI,coordsTmp,types1D); ret1D=0;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsTmpSafe(coordsTmp);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn1DSafe(conn1D),conn1DISafe(conn1DI);
+ const int *c1DPtr=conn1D->begin();
+ const int *c1DIPtr=conn1DI->begin();
+ int nbOfCells=getNumberOfCells();
+ const int *cPtr=_nodal_connec->getConstPointer();
+ const int *icPtr=_nodal_connec_index->getConstPointer();
+ int lastVal=0,offset=coordsTmpSafe->getNumberOfTuples();
+ for(int i=0;i<nbOfCells;i++,icPtr++,descIPtr++)
+ {
+ INTERP_KERNEL::NormalizedCellType typ=(INTERP_KERNEL::NormalizedCellType)cPtr[*icPtr];
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
+ if(!cm.isQuadratic())
+ {
+ INTERP_KERNEL::NormalizedCellType typ2=cm.getQuadraticType2();
+ types.insert(typ2); newConn->pushBackSilent(typ2);
+ newConn->pushBackValsSilent(cPtr+icPtr[0]+1,cPtr+icPtr[1]);
+ for(const int *d=descPtr+descIPtr[0];d!=descPtr+descIPtr[1];d++)
+ newConn->pushBackSilent(c1DPtr[c1DIPtr[*d]+3]);
+ newConn->pushBackSilent(offset+ret->getNumberOfTuples());
+ lastVal+=(icPtr[1]-icPtr[0])+(descIPtr[1]-descIPtr[0])+1;
+ newConnI->pushBackSilent(lastVal);
+ ret->pushBackSilent(i);
+ }
+ else
+ {
+ types.insert(typ);
+ lastVal+=(icPtr[1]-icPtr[0]);
+ newConnI->pushBackSilent(lastVal);
+ newConn->pushBackValsSilent(cPtr+icPtr[0],cPtr+icPtr[1]);
+ }
+ }
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp=bary->selectByTupleIdSafe(ret->begin(),ret->end());
+ coords=DataArrayDouble::Aggregate(coordsTmpSafe,tmp); conn=newConn.retn(); connI=newConnI.retn();
+ return ret.retn();
+}
+
/*!
* Implementes \a conversionType 0 for meshes with meshDim = 3, of MEDCouplingUMesh::convertLinearCellsToQuadratic method.
* \return a newly created DataArrayInt instance that the caller should deal with containing cell ids of converted cells.
return convertLinearCellsToQuadratic2DAnd3D0(m1D,desc,descI,conn,connI,coords,types);
}
+DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic3D1(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> desc2(DataArrayInt::New()),desc2I(DataArrayInt::New()),tmp2(DataArrayInt::New()),tmp3(DataArrayInt::New());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m2D=buildDescendingConnectivityGen<MinusOneSonsGeneratorBiQuadratic>(desc2,desc2I,tmp2,tmp3,MEDCouplingFastNbrer); tmp2=0; tmp3=0;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> desc1(DataArrayInt::New()),desc1I(DataArrayInt::New()),tmp4(DataArrayInt::New()),tmp5(DataArrayInt::New());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m1D=explode3DMeshTo1D(desc1,desc1I,tmp4,tmp5); tmp4=0; tmp5=0;
+ //
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConn=DataArrayInt::New(); newConn->alloc(0,1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConnI=DataArrayInt::New(); newConnI->alloc(1,1); newConnI->setIJ(0,0,0);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New(),ret2=DataArrayInt::New(); ret->alloc(0,1); ret2->alloc(0,1);
+ //
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> bary=getBarycenterAndOwner();
+ const int *descPtr(desc1->begin()),*descIPtr(desc1I->begin()),*desc2Ptr(desc2->begin()),*desc2IPtr(desc2I->begin());
+ DataArrayInt *conn1D=0,*conn1DI=0,*conn2D=0,*conn2DI=0;
+ std::set<INTERP_KERNEL::NormalizedCellType> types1D,types2D;
+ DataArrayDouble *coordsTmp=0,*coordsTmp2=0;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret1D=m1D->convertLinearCellsToQuadratic1D0(conn1D,conn1DI,coordsTmp,types1D); ret1D=DataArrayInt::New(); ret1D->alloc(0,1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn1DSafe(conn1D),conn1DISafe(conn1DI);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsTmpSafe(coordsTmp);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret2D=m2D->convertLinearCellsToQuadratic2D1(conn2D,conn2DI,coordsTmp2,types2D); ret2D=DataArrayInt::New(); ret2D->alloc(0,1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsTmp2Safe(coordsTmp2);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn2DSafe(conn2D),conn2DISafe(conn2DI);
+ const int *c1DPtr=conn1D->begin(),*c1DIPtr=conn1DI->begin(),*c2DPtr=conn2D->begin(),*c2DIPtr=conn2DI->begin();
+ int nbOfCells=getNumberOfCells();
+ const int *cPtr=_nodal_connec->getConstPointer();
+ const int *icPtr=_nodal_connec_index->getConstPointer();
+ int lastVal=0,offset=coordsTmpSafe->getNumberOfTuples();
+ for(int i=0;i<nbOfCells;i++,icPtr++,descIPtr++,desc2IPtr++)
+ {
+ INTERP_KERNEL::NormalizedCellType typ=(INTERP_KERNEL::NormalizedCellType)cPtr[*icPtr];
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
+ if(!cm.isQuadratic())
+ {
+ INTERP_KERNEL::NormalizedCellType typ2=cm.getQuadraticType2();
+ if(typ2==INTERP_KERNEL::NORM_ERROR)
+ {
+ std::ostringstream oss; oss << "MEDCouplingUMesh::convertLinearCellsToQuadratic3D1 : On cell #" << i << " the linear cell type does not support advanced quadratization !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ types.insert(typ2); newConn->pushBackSilent(typ2);
+ newConn->pushBackValsSilent(cPtr+icPtr[0]+1,cPtr+icPtr[1]);
+ for(const int *d=descPtr+descIPtr[0];d!=descPtr+descIPtr[1];d++)
+ newConn->pushBackSilent(c1DPtr[c1DIPtr[*d]+3]);
+ for(const int *d=desc2Ptr+desc2IPtr[0];d!=desc2Ptr+desc2IPtr[1];d++)
+ {
+ int nodeId2=c2DPtr[c2DIPtr[(*d)+1]-1];
+ int tmpPos=newConn->getNumberOfTuples();
+ newConn->pushBackSilent(nodeId2);
+ ret2D->pushBackSilent(nodeId2); ret1D->pushBackSilent(tmpPos);
+ }
+ newConn->pushBackSilent(offset+ret->getNumberOfTuples());
+ lastVal+=(icPtr[1]-icPtr[0])+(descIPtr[1]-descIPtr[0])+(desc2IPtr[1]-desc2IPtr[0])+1;
+ newConnI->pushBackSilent(lastVal);
+ ret->pushBackSilent(i);
+ }
+ else
+ {
+ types.insert(typ);
+ lastVal+=(icPtr[1]-icPtr[0]);
+ newConnI->pushBackSilent(lastVal);
+ newConn->pushBackValsSilent(cPtr+icPtr[0],cPtr+icPtr[1]);
+ }
+ }
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffRet2D=ret2D->getDifferentValues();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2nRet2D=diffRet2D->invertArrayN2O2O2N(coordsTmp2Safe->getNumberOfTuples());
+ coordsTmp2Safe=coordsTmp2Safe->selectByTupleId(diffRet2D->begin(),diffRet2D->end());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp=bary->selectByTupleIdSafe(ret->begin(),ret->end());
+ std::vector<const DataArrayDouble *> v(3); v[0]=coordsTmpSafe; v[1]=coordsTmp2Safe; v[2]=tmp;
+ int *c=newConn->getPointer();
+ const int *cI(newConnI->begin());
+ for(const int *elt=ret1D->begin();elt!=ret1D->end();elt++)
+ c[*elt]=o2nRet2D->getIJ(c[*elt],0)+offset;
+ offset=coordsTmp2Safe->getNumberOfTuples();
+ for(const int *elt=ret->begin();elt!=ret->end();elt++)
+ c[cI[(*elt)+1]-1]+=offset;
+ coords=DataArrayDouble::Aggregate(v); conn=newConn.retn(); connI=newConnI.retn();
+ return ret.retn();
+}
+
/*!
* This method tessallates 'this' so that the number of cells remains the same.
* This method works only for meshes with spaceDim equal to 2 and meshDim equal to 2.
* nodal connectivity will be transform to a NORM_TRI3 cell.
* This method works \b only \b on \b linear cells.
* This method works on nodes ids, that is to say a call to ParaMEDMEM::MEDCouplingUMesh::mergeNodes
- * method could be usefull before calling this method in case of presence of several pair of nodes located on same position.
+ * method could be useful before calling this method in case of presence of several pair of nodes located on same position.
* This method throws an exception if 'this' is not fully defined (connectivity).
* This method throws an exception too if a "too" degenerated cell is detected. For example a NORM_TRI3 with 3 times the same node id.
*/
/*!
* This method sorts cell in this so that cells are sorted by cell type specified by MEDMEM and so for MED file.
- * It avoids to deal with renum in MEDLoader so it is usefull for MED file R/W with multi types.
+ * It avoids to deal with renum in MEDLoader so it is useful for MED file R/W with multi types.
* This method returns a newly allocated array old2New.
* This method expects that connectivity of this is set. If not an exception will be thrown. Coordinates are not taken into account.
*/
/*!
* This method performs the same job as checkConsecutiveCellTypes except that the order of types sequence is analyzed to check
- * that the order is specified in array defined by [orderBg,orderEnd).
+ * that the order is specified in array defined by [orderBg,orderEnd).
+ * If there is some geo types in \a this \b NOT in [ \a orderBg, \a orderEnd ) it is OK (return true) if contiguous.
+ * If there is some geo types in [ \a orderBg, \a orderEnd ) \b NOT in \a this it is OK too (return true) if contiguous.
*/
bool MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const
{
const int *conn=_nodal_connec->getConstPointer();
const int *connI=_nodal_connec_index->getConstPointer();
int nbOfCells=getNumberOfCells();
+ if(nbOfCells==0)
+ return true;
int lastPos=-1;
+ std::set<INTERP_KERNEL::NormalizedCellType> sg;
for(const int *i=connI;i!=connI+nbOfCells;)
{
INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i];
- int pos=(int)std::distance(orderBg,std::find(orderBg,orderEnd,curType));
- if(pos<=lastPos)
- return false;
- lastPos=pos;
- i=std::find_if(i+1,connI+nbOfCells,ParaMEDMEMImpl::ConnReader(conn,(int)curType));
+ const INTERP_KERNEL::NormalizedCellType *isTypeExists=std::find(orderBg,orderEnd,curType);
+ if(isTypeExists!=orderEnd)
+ {
+ int pos=(int)std::distance(orderBg,isTypeExists);
+ if(pos<=lastPos)
+ return false;
+ lastPos=pos;
+ i=std::find_if(i+1,connI+nbOfCells,ParaMEDMEMImpl::ConnReader(conn,(int)curType));
+ }
+ else
+ {
+ if(sg.find(curType)==sg.end())
+ {
+ i=std::find_if(i+1,connI+nbOfCells,ParaMEDMEMImpl::ConnReader(conn,(int)curType));
+ sg.insert(curType);
+ }
+ else
+ return false;
+ }
}
return true;
}
* But mesh in \b meshes \b can \b have \b different \b mesh \b dimension \b each \b other.
*
* This method performs nothing if size of \b meshes is in [0,1].
- * This method is particulary usefull in MEDLoader context to build a \ref ParaMEDMEM::MEDFileUMesh "MEDFileUMesh" instance that expects that underlying
+ * This method is particulary useful in MEDLoader context to build a \ref ParaMEDMEM::MEDFileUMesh "MEDFileUMesh" instance that expects that underlying
* coordinates DataArrayDouble instance.
*
* \param [in,out] meshes : vector containing no null instance of MEDCouplingUMesh that in case of success of this method will be modified.
* If \b meshes share the same instance of DataArrayDouble as coordinates and that this instance is null, this method do nothing and no exception will be thrown.
*
* This method performs nothing if size of \b meshes is empty.
- * This method is particulary usefull in MEDLoader context to perform a treatment of a MEDFileUMesh instance on different levels.
+ * This method is particulary useful in MEDLoader context to perform a treatment of a MEDFileUMesh instance on different levels.
* coordinates DataArrayDouble instance.
*
* \param [in,out] meshes :vector containing no null instance of MEDCouplingUMesh sharing the same DataArrayDouble instance of coordinates, that in case of success of this method will be modified.
int nbOfCells=getNumberOfCells();
if(nbOfCells<=0)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::writeVTK : the unstructured mesh has no cells !");
- static const int PARAMEDMEM2VTKTYPETRADUCER[INTERP_KERNEL::NORM_MAXTYPE+1]={1,3,21,5,9,7,22,-1,23,-1,-1,-1,-1,-1,10,14,13,-1,12,-1,24,-1,16,27,-1,26,-1,-1,-1,-1,25,42,-1,4};
+ static const int PARAMEDMEM2VTKTYPETRADUCER[INTERP_KERNEL::NORM_MAXTYPE+1]={1,3,21,5,9,7,22,34,23,28,-1,-1,-1,-1,10,14,13,-1,12,-1,24,-1,16,27,-1,26,-1,29,-1,-1,25,42,-1,4};
ofs << " <" << getVTKDataSetType() << ">\n";
ofs << " <Piece NumberOfPoints=\"" << getNumberOfNodes() << "\" NumberOfCells=\"" << nbOfCells << "\">\n";
ofs << " <PointData>\n" << pointData << std::endl;
* This method start from id 0 that will be contained in output DataArrayInt. It searches then all neighbors of id0 regarding arrIn[arrIndxIn[0]:arrIndxIn[0+1]].
* Then it is repeated recursively until either all ids are fetched or no more ids are reachable step by step.
* A negative value in \b arrIn means that it is ignored.
- * This method is usefull to see if a mesh is contiguous regarding its connectivity. If it is not the case the size of returned array is different from arrIndxIn->getNumberOfTuples()-1.
+ * This method is useful to see if a mesh is contiguous regarding its connectivity. If it is not the case the size of returned array is different from arrIndxIn->getNumberOfTuples()-1.
*
* \param [in] arrIn arr origin array from which the extraction will be done.
* \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
* This method start from id 0 that will be contained in output DataArrayInt. It searches then all neighbors of id0 regarding arrIn[arrIndxIn[0]:arrIndxIn[0+1]].
* Then it is repeated recursively until either all ids are fetched or no more ids are reachable step by step.
* A negative value in \b arrIn means that it is ignored.
- * This method is usefull to see if a mesh is contiguous regarding its connectivity. If it is not the case the size of returned array is different from arrIndxIn->getNumberOfTuples()-1.
+ * This method is useful to see if a mesh is contiguous regarding its connectivity. If it is not the case the size of returned array is different from arrIndxIn->getNumberOfTuples()-1.
* \param [in] seedBg the begin pointer (included) of an array containing the seed of the search zone
* \param [in] seedEnd the end pointer (not included) of an array containing the seed of the search zone
* \param [in] arrIn arr origin array from which the extraction will be done.
DataArrayInt *convertLinearCellsToQuadratic1D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception);
DataArrayInt *convertLinearCellsToQuadratic2DAnd3D0(const MEDCouplingUMesh *m1D, const DataArrayInt *desc, const DataArrayInt *descI, DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception);
DataArrayInt *convertLinearCellsToQuadratic2D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *convertLinearCellsToQuadratic2D1(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception);
DataArrayInt *convertLinearCellsToQuadratic3D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *convertLinearCellsToQuadratic3D1(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception);
template<int SPACEDIM>
void getCellsContainingPointsAlg(const double *coords, const double *pos, int nbOfPoints,
double eps, std::vector<int>& elts, std::vector<int>& eltsIndex) const;
m1->decrRef();
m2->decrRef();
}
+
+void MEDCouplingBasicsTest1::testSetConnectivity()
+{
+ MEDCouplingUMesh *m1 = build1DTargetMesh_1();
+
+ DataArrayInt * conn = DataArrayInt::New();
+ DataArrayInt * connI = DataArrayInt::New();
+ m1->setConnectivity(conn, connI, true); // was SEG-Faulting with empty arrays
+ conn->decrRef();
+ connI->decrRef();
+ m1->decrRef();
+}
CPPUNIT_TEST( testFindNodeOnPlane );
CPPUNIT_TEST( testRenumberCells );
CPPUNIT_TEST( testChangeSpaceDimension );
+ CPPUNIT_TEST( testSetConnectivity );
CPPUNIT_TEST_SUITE_END();
public:
void testArray();
void testFindNodeOnPlane();
void testRenumberCells();
void testChangeSpaceDimension();
+ void testSetConnectivity();
};
}
//
MEDCouplingUMesh *m=build2DTargetMesh_1();
MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,NO_TIME);
+ CPPUNIT_ASSERT_THROW(f->getNumberOfTuples(), INTERP_KERNEL::Exception); // Sanity check!
f->setMesh(m);
CPPUNIT_ASSERT_EQUAL(5,f->getNumberOfMeshPlacesExpected());
CPPUNIT_ASSERT_EQUAL(0,f->getNbOfGaussLocalization());
CPPUNIT_ASSERT_DOUBLES_EQUAL(8.,f->getMaxValue(),1e-14);
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,f->getMinValue(),1e-14);
CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,f->getAverageValue(),1e-14);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(5.125,f->getWeightedAverageValue(),1e-14);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(5.125,f->getWeightedAverageValue(0),1e-14);
a1->setIJ(0,2,9.5);
CPPUNIT_ASSERT_DOUBLES_EQUAL(9.5,f->getMaxValue(),1e-14);
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,f->getMinValue(),1e-14);
const int arr[12]={1,2,3,2,2,3,5,1,5,5,2,2};
da1->alloc(4,3);
std::copy(arr,arr+12,da1->getPointer());
- std::set<int> s=da1->getDifferentValues();
+ DataArrayInt *s=da1->getDifferentValues();
const int expected1[4]={1,2,3,5};
- CPPUNIT_ASSERT_EQUAL(4,(int)s.size());
- CPPUNIT_ASSERT(std::equal(expected1,expected1+4,s.begin()));
+ CPPUNIT_ASSERT_EQUAL(4,s->getNumberOfTuples());
+ CPPUNIT_ASSERT(std::equal(expected1,expected1+4,s->begin()));
da1->decrRef();
+ s->decrRef();
}
void MEDCouplingBasicsTest3::testDAIBuildPermutationArr1()
#include "MEDCouplingMemArray.hxx"
#include "MEDCouplingMultiFields.hxx"
+void CppExample_DataArrayInt_buildPermutationArr()
+{
+ using namespace ParaMEDMEM;
+ //! [CppSnippet_DataArrayInt_buildPermutationArr_1]
+ DataArrayInt *a=DataArrayInt::New();
+ const int vala[5]={4,5,6,7,8};
+ a->alloc(5,1);
+ std::copy(vala,vala+5,a->getPointer());
+ DataArrayInt *b=DataArrayInt::New();
+ const int valb[5]={5,4,8,6,7};
+ b->alloc(5,1);
+ std::copy(valb,valb+5,b->getPointer());
+ DataArrayInt *c=a->buildPermutationArr(*b);
+ //! [CppSnippet_DataArrayInt_buildPermutationArr_1]
+ const int expect1[5]={1,0,4,2,3};
+ CPPUNIT_ASSERT_EQUAL(5,c->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,c->getNumberOfComponents());
+ CPPUNIT_ASSERT(std::equal(expect1,expect1+5,c->getConstPointer()));
+ CPPUNIT_ASSERT(a->isEqualWithoutConsideringStrAndOrder(*b));
+ a->decrRef();
+ b->decrRef();
+ c->decrRef();
+}
+
+void CppExample_DataArrayInt_invertArrayO2N2N2O()
+{
+ using namespace ParaMEDMEM;
+ //! [CppSnippet_DataArrayInt_invertArrayO2N2N2O_1]
+ const int arr1[6]={2,0,4,1,5,3};
+ DataArrayInt *da=DataArrayInt::New();
+ da->alloc(6,1);
+ std::copy(arr1,arr1+6,da->getPointer());
+ DataArrayInt *da2=da->invertArrayO2N2N2O(6);
+ const int expected1[6]={1,3,0,5,2,4};
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(i,0));
+ //! [CppSnippet_DataArrayInt_invertArrayO2N2N2O_1]
+ da->decrRef();
+ da2->decrRef();
+}
+
+void CppExample_DataArrayInt_invertArrayN2O2O2N()
+{
+ using namespace ParaMEDMEM;
+ //! [CppSnippet_DataArrayInt_invertArrayN2O2O2N_1]
+ const int arr1[6]={2,0,4,1,5,3};
+ DataArrayInt *da=DataArrayInt::New();
+ da->alloc(6,1);
+ std::copy(arr1,arr1+6,da->getPointer());
+ DataArrayInt *da2=da->invertArrayN2O2O2N(6);
+ const int expected1[6]={1,3,0,5,2,4};
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(i,0));
+ //! [CppSnippet_DataArrayInt_invertArrayN2O2O2N_1]
+ da->decrRef();
+ da2->decrRef();
+}
+
+void CppExample_DataArrayDouble_getIdsInRange()
+{
+ using namespace ParaMEDMEM;
+ //! [CppSnippet_DataArrayDouble_getIdsInRange_1]
+ DataArrayDouble *da=DataArrayDouble::New();
+ da->alloc(10,1);
+ da->iota();
+
+ DataArrayInt* da2 = da->getIdsInRange( 2.5, 6 );
+ //! [CppSnippet_DataArrayDouble_getIdsInRange_1]
+ da->decrRef();
+ da2->decrRef();
+}
+
+void CppExample_DataArrayDouble_findCommonTuples()
+{
+ using namespace ParaMEDMEM;
+ //! [CppSnippet_DataArrayDouble_findCommonTuples1]
+ DataArrayDouble *da=DataArrayDouble::New();
+ da->alloc(6,2);
+ const double array2[12]={2.3,2.3, // 0
+ 1.2,1.2, // 1
+ 1.3,1.3, // 2
+ 2.3,2.3, // 3
+ 2.301, // 4
+ 2.301, // 5
+ 0.8,0.8};// 6
+ std::copy(array2,array2+12,da->getPointer());
+ //! [CppSnippet_DataArrayDouble_findCommonTuples1]
+ //! [CppSnippet_DataArrayDouble_findCommonTuples2]
+ DataArrayInt *c=0,*cI=0;
+ da->findCommonTuples(1e-1,-1,c,cI);
+
+ const int expected3[5]={0,3,4,1,2};
+ const int expected4[3]={0,3,5};
+ CPPUNIT_ASSERT(std::equal(expected3,expected3+5,c->getConstPointer()));
+ CPPUNIT_ASSERT(std::equal(expected4,expected4+3,cI->getConstPointer()));
+ c->decrRef();
+ cI->decrRef();
+ da->decrRef();
+ //! [CppSnippet_DataArrayDouble_findCommonTuples2]
+}
+
+void CppExample_DataArrayDouble_Meld1()
+{
+ using namespace ParaMEDMEM;
+ //! [CppSnippet_DataArrayDouble_Meld1_1]
+ const int sameNbTuples = 7;
+
+ DataArrayDouble *da1=DataArrayDouble::New();
+ da1->alloc(sameNbTuples,2);
+ da1->fillWithValue(7.);
+ da1->setInfoOnComponent(0,"c0da1");
+ da1->setInfoOnComponent(1,"c1da1");
+
+ DataArrayDouble *da2=DataArrayDouble::New();
+ da2->alloc(sameNbTuples,1);
+ da2->iota(0.);
+ da2->setInfoOnComponent(0,"c0da2");
+
+ da1->meldWith(da2);
+ //! [CppSnippet_DataArrayDouble_Meld1_1]
+ //! [CppSnippet_DataArrayDouble_Meld1_2]
+ da1->decrRef();
+ da2->decrRef();
+ //! [CppSnippet_DataArrayDouble_Meld1_2]
+}
+
+void CppExample_DataArrayInt_Meld1()
+{
+ using namespace ParaMEDMEM;
+ //! [CppSnippet_DataArrayInt_Meld1_1]
+ const int sameNbTuples = 7;
+
+ DataArrayInt *da1=DataArrayInt::New();
+ da1->alloc(sameNbTuples,2);
+ da1->fillWithValue(7);
+ da1->setInfoOnComponent(0,"c0da1");
+ da1->setInfoOnComponent(1,"c1da1");
+
+ DataArrayInt *da2=DataArrayInt::New();
+ da2->alloc(sameNbTuples,1);
+ da2->iota(0);
+ da2->setInfoOnComponent(0,"c0da2");
+
+ da1->meldWith(da2);
+ //! [CppSnippet_DataArrayInt_Meld1_1]
+ //! [CppSnippet_DataArrayInt_Meld1_2]
+ da1->decrRef();
+ da2->decrRef();
+ //! [CppSnippet_DataArrayInt_Meld1_2]
+}
+
void CppExampleFieldDoubleBuildSubPart1()
{
//! [CppSnippetFieldDoubleBuildSubPart1_1]
myCoords->useArray(coords,false,ParaMEDMEM::CPP_DEALLOC,nbOfNodes,3);
//now use myCoords as you need
//...
- //myCoords is no more usefully here : release it
+ //myCoords is no more useful here : release it
myCoords->decrRef();
//! [CppSnippetDataArrayBuild1_1]
//! [CppSnippetDataArrayBuild1_2]
myCoords->useArray(tmp,true,ParaMEDMEM::CPP_DEALLOC,nbOfNodes,3);
//now use myCoords as you need
//...
- //myCoords is no more usefully, release it
+ //myCoords is no more useful, release it
myCoords->decrRef();
//! [CppSnippetDataArrayBuild1_2]
//! [CppSnippetDataArrayBuild1_3]
myCoords->useArray(tmp,true,ParaMEDMEM::C_DEALLOC,nbOfNodes,3);
//now use myCoords as you need
//...
- //myCoords is no more usefully here : release it
+ //myCoords is no more useful here : release it
myCoords->decrRef();
//! [CppSnippetDataArrayBuild1_3]
//! [CppSnippetDataArrayBuild1_4]
myCoords->declareAsNew();//you have modified data pointed by internal pointer notify object
//now use myCoords as you need
//...
- //myCoords is no more usefully here : release it
+ //myCoords is no more useful here : release it
myCoords->decrRef();
//! [CppSnippetDataArrayBuild1_4]
myCoords=ParaMEDMEM::DataArrayDouble::New();
myCoordsCpy->decrRef();
//! [CppSnippetDataArrayBuild1_14]
myCoords->decrRef();
+ //! [CppSnippetDataArrayBuild1_14]
}
void CppSnippetFieldDoubleBuild1()
array->decrRef();
// fieldOnCells is now usable
// ...
- // fieldOnCells is no more usefully here : release it
+ // fieldOnCells is no more useful here : release it
fieldOnCells->decrRef();
//! [CppSnippetFieldDoubleBuild1_1]
arrX=ParaMEDMEM::DataArrayDouble::New(); arrX->alloc(9,1); std::copy(XCoords,XCoords+9,arrX->getPointer()); arrX->setInfoOnComponent(0,"X [m]");
//! [CppSnippetFieldDoubleBuild1_2]
mesh->decrRef();
//! [CppSnippetFieldDoubleBuild1_3]
- // f1, f2, f2bis, f3, f4, f5 are no more usefully here : release them
+ // f1, f2, f2bis, f3, f4, f5 are no more useful here : release them
f1->decrRef();
f2->decrRef();
f2bis->decrRef();
array->decrRef();
// fieldOnNodes is now usable
// ...
- // fieldOnNodes is no more usefully here : release it
+ // fieldOnNodes is no more useful here : release it
fieldOnNodes->decrRef();
//! [CppSnippetFieldDoubleBuild2_1]
}
array->decrRef();
// fieldOnCells is now usable
// ...
- // fieldOnCells is no more usefully here : release it
+ // fieldOnCells is no more useful here : release it
fieldOnCells->decrRef();
//! [CppSnippetFieldDoubleBuild3_1]
}
array->decrRef();
// fieldOnNodes is now usable
// ...
- // fieldOnNodes is no more usefully here : release it
+ // fieldOnNodes is no more useful here : release it
fieldOnNodes->decrRef();
//! [CppSnippetFieldDoubleBuild4_1]
}
int main(int argc, char *argv[])
{
+ CppExample_DataArrayInt_buildPermutationArr();
+ CppExample_DataArrayInt_invertArrayO2N2N2O();
+ CppExample_DataArrayInt_invertArrayN2O2O2N();
+ CppExample_DataArrayDouble_getIdsInRange();
+ CppExample_DataArrayDouble_findCommonTuples();
+ CppExample_DataArrayDouble_Meld1();
CppExampleFieldDoubleBuildSubPart1();
CppSnippetUMeshStdBuild1();
CppSnippetUMeshAdvBuild1();
void MEDCouplingMultiFieldsServant::getTinyInfo(CORBA::Long id, SALOME_TYPES::ListOfLong_out la, SALOME_TYPES::ListOfDouble_out da, SALOME_TYPES::ListOfString_out sa)
{
const MEDCouplingFieldDouble *f=getPointer()->getFieldWithId(id);
- MEDCouplingFieldTemplate *f2=MEDCouplingFieldTemplate::New(f);
+ MEDCouplingFieldTemplate *f2=MEDCouplingFieldTemplate::New(*f);
la=new SALOME_TYPES::ListOfLong;
std::vector<int> tinyInfo;
f2->getTinySerializationIntInformation(tinyInfo);
void MEDCouplingMultiFieldsServant::getSerialisationData(CORBA::Long id, SALOME_TYPES::ListOfLong_out la)
{
const MEDCouplingFieldDouble *f=getPointer()->getFieldWithId(id);
- MEDCouplingFieldTemplate *f2=MEDCouplingFieldTemplate::New(f);
+ MEDCouplingFieldTemplate *f2=MEDCouplingFieldTemplate::New(*f);
DataArrayInt *dataInt;
f2->serialize(dataInt);
//
ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateCellOn2D()
{
ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldScalarOn2DNT();
- ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(f1);
+ ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(*f1);
f2->setNature(ParaMEDMEM::NoNature);
f1->decrRef();
return f2;
ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateNodeOn2D()
{
ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldNodeScalarOn2DNT();
- ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(f1);
+ ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(*f1);
f2->setNature(ParaMEDMEM::ConservativeVolumic);
f1->decrRef();
return f2;
ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateGaussPtOn2D()
{
ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldGaussPt2DWT();
- ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(f1);
+ ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(*f1);
f2->setNature(ParaMEDMEM::Integral);
f1->decrRef();
return f2;
ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateGaussNEOn2D()
{
ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldGaussPtNE2DWT();
- ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(f1);
+ ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(*f1);
f2->setNature(ParaMEDMEM::IntegralGlobConstraint);
f1->decrRef();
return f2;
PyRun_String("import CORBA", Py_single_input, pdict, pdict);
PyRun_String("orbTmp15634=CORBA.ORB_init([''])",Py_single_input,pdict, pdict);
PyObject* orbPython=PyDict_GetItemString(pdict,"orbTmp15634");
- PyObject *corbaObj=PyObject_CallMethod(orbPython,(char*)"string_to_object",(char*)"O",iorPython);
+ PyObject *corbaObj=PyObject_CallMethod(orbPython,const_cast<char*>("string_to_object"),const_cast<char*>("O"),iorPython);
Py_DECREF(pdict);
Py_DECREF(iorPython);
CORBA::string_free(ior);
self.assertAlmostEqual(8.,f.getMaxValue(),14);
self.assertAlmostEqual(0.,f.getMinValue(),14);
self.assertAlmostEqual(5.,f.getAverageValue(),14);
- self.assertAlmostEqual(5.125,f.getWeightedAverageValue(),14);
+ self.assertAlmostEqual(5.125,f.getWeightedAverageValue(0,True),14);
a1.setIJ(0,2,9.5);
self.assertAlmostEqual(9.5,f.getMaxValue(),14);
self.assertAlmostEqual(0.,f.getMinValue(),14);
arr=[1,2,3,2,2,3,5,1,5,5,2,2]
da1.setValues(arr,4,3);
s=da1.getDifferentValues();
- expected1=[1,2,3,5]
- self.assertEqual(expected1,s);
+ expected1=DataArrayInt([1,2,3,5])
+ self.assertTrue(expected1.isEqual(s));
pass
def testSwigErrorProtection3(self):
self.assertTrue(a.getCoords().isEqual(DataArrayDouble([-0.3,-0.3,0.0,0.2,-0.3,0.0,0.7,-0.3,0.0,-0.3,0.2,0.0,0.2,0.2,0.0,0.7,0.2,0.0,-0.3,0.7,0.0,0.2,0.7,0.0,0.7,0.7,0.0,-0.3,-0.3,1.0,0.2,-0.3,1.0,0.7,-0.3,1.0,-0.3,0.2,1.0,0.2,0.2,1.0,0.7,0.2,1.0,-0.3,0.7,1.0,0.2,0.7,1.0,0.7,0.7,1.0,-0.3,-0.05,0.0,-0.05,0.2,0.0,0.2,-0.05,0.0,-0.05,-0.3,0.0,-0.3,-0.05,1.0,-0.05,0.2,1.0,0.2,-0.05,1.0,-0.05,-0.3,1.0,-0.3,-0.3,0.5,-0.3,0.2,0.5,0.2,0.2,0.5,0.2,-0.3,0.5,0.45,-0.05,0.0,0.45,-0.3,0.0,0.45,-0.05,1.0,0.45,-0.3,1.0,0.7,-0.3,0.5,0.45,0.2,0.0,0.7,-0.05,0.0,0.45,0.2,1.0,0.7,-0.05,1.0,0.7,0.2,0.5,-0.05,0.7,0.0,0.2,0.45,0.0,-0.3,0.45,0.0,-0.05,0.7,1.0,0.2,0.45,1.0,-0.3,0.45,1.0,-0.3,0.7,0.5,0.2,0.7,0.5,0.45,0.7,0.0,0.7,0.45,0.0,0.45,0.7,1.0,0.7,0.45,1.0,0.7,0.7,0.5],53,3),1e-14))
pass
+ def testSwig2DataArrayPushBackValsSilent1(self):
+ d=DataArrayDouble()
+ d.pushBackValsSilent([4,5,6])
+ self.assertTrue(d.isEqual(DataArrayDouble([4.,5.,6.]),1e-14))
+ e=DataArrayDouble([1,2,3],1,3)
+ for t in e: d.pushBackValsSilent(t)
+ self.assertTrue(d.isEqual(DataArrayDouble([4.,5.,6.,1.,2.,3.]),1e-14))
+ d.pushBackValsSilent(DataArrayDouble([9,10.]))
+ self.assertTrue(d.isEqual(DataArrayDouble([4.,5.,6.,1.,2.,3.,9.,10.]),1e-14))
+ d.pushBackValsSilent(DataArrayDouble(0,1))
+ self.assertTrue(d.isEqual(DataArrayDouble([4.,5.,6.,1.,2.,3.,9.,10.]),1e-14))
+ e=DataArrayDouble([1,2,3],3,1)
+ for t in e: d.pushBackValsSilent(t)
+ self.assertTrue(d.isEqual(DataArrayDouble([4.,5.,6.,1.,2.,3.,9.,10.,1.,2.,3.]),1e-14))
+ d.pushBackValsSilent(77)
+ self.assertTrue(d.isEqual(DataArrayDouble([4.,5.,6.,1.,2.,3.,9.,10.,1.,2.,3.,77.]),1e-14))
+ #
+ d=DataArrayInt()
+ d.pushBackValsSilent([4,5,6])
+ self.assertTrue(d.isEqual(DataArrayInt([4,5,6])))
+ e=DataArrayInt([1,2,3],1,3)
+ for t in e: d.pushBackValsSilent(t)
+ self.assertTrue(d.isEqual(DataArrayInt([4,5,6,1,2,3])))
+ d.pushBackValsSilent(DataArrayInt([9,10]))
+ self.assertTrue(d.isEqual(DataArrayInt([4,5,6,1,2,3,9,10])))
+ d.pushBackValsSilent(DataArrayInt(0,1))
+ self.assertTrue(d.isEqual(DataArrayInt([4,5,6,1,2,3,9,10])))
+ e=DataArrayInt([1,2,3],3,1)
+ for t in e: d.pushBackValsSilent(t)
+ self.assertTrue(d.isEqual(DataArrayInt([4,5,6,1,2,3,9,10,1,2,3])))
+ d.pushBackValsSilent(77)
+ self.assertTrue(d.isEqual(DataArrayInt([4,5,6,1,2,3,9,10,1,2,3,77])))
+ pass
+
+ def testSwig2ConvertLinearCellsToQuadratic2(self):
+ m2D=MEDCouplingDataForTest.build2DTargetMesh_1()
+ ret=m2D.convertLinearCellsToQuadratic(1)
+ self.assertTrue(ret.isIdentity())
+ self.assertEqual(5,len(ret))
+ m2D.checkCoherency1()
+ coordsExp=DataArrayDouble([-0.3,-0.3,0.2,-0.3,0.7,-0.3,-0.3,0.2,0.2,0.2,0.7,0.2,-0.3,0.7,0.2,0.7,0.7,0.7,-0.3,-0.05,-0.05,0.2,0.2,-0.05,-0.05,-0.3,0.45,-0.05,0.45,-0.3,0.45,0.2,0.7,-0.05,-0.05,0.7,0.2,0.45,-0.3,0.45,0.45,0.7,0.7,0.45,-0.05,-0.05,0.3666666666666667,-0.1333333333333333,0.5333333333333332,0.03333333333333334,-0.05,0.45,0.45,0.45],27,2)
+ self.assertTrue(m2D.getCoords().isEqual(coordsExp,1e-14))
+ self.assertTrue(m2D.getNodalConnectivity().isEqual(DataArrayInt([9,0,3,4,1,9,10,11,12,22,7,1,4,2,11,13,14,23,7,4,5,2,15,16,13,24,9,6,7,4,3,17,18,10,19,25,9,7,8,5,4,20,21,15,18,26])))
+ self.assertTrue(m2D.getNodalConnectivityIndex().isEqual(DataArrayInt([0,10,18,26,36,46])))
+ #
+ m2D=MEDCouplingDataForTest.build2DTargetMesh_1()[(0,3)] ; m2D.zipCoords()
+ m2D.changeSpaceDimension(3)
+ arr=DataArrayDouble(3); arr.iota(0) ; z=MEDCouplingCMesh() ; z.setCoords(arr)
+ m1D=z.buildUnstructured() ; m1D.setCoords(arr.changeNbOfComponents(3,0.))
+ m1D.getCoords()[:]=m1D.getCoords()[:,[1,2,0]]
+ cooTmp=m2D.getCoords()[:]
+ m3D=m2D.buildExtrudedMesh(m1D,0)
+ ret=m3D.convertLinearCellsToQuadratic(1)
+ m3D.writeVTK("m3D.vtu")
+ self.assertTrue(ret.isIdentity())
+ self.assertEqual(4,len(ret))
+ m3D.checkCoherency1()
+ coordsExp2=DataArrayDouble([-0.3,-0.3,0.0,0.2,-0.3,0.0,-0.3,0.2,0.0,0.2,0.2,0.0,-0.3,0.7,0.0,0.2,0.7,0.0,-0.3,-0.3,1.0,0.2,-0.3,1.0,-0.3,0.2,1.0,0.2,0.2,1.0,-0.3,0.7,1.0,0.2,0.7,1.0,-0.3,-0.3,2.0,0.2,-0.3,2.0,-0.3,0.2,2.0,0.2,0.2,2.0,-0.3,0.7,2.0,0.2,0.7,2.0,-0.3,-0.05,0.0,-0.05,0.2,0.0,0.2,-0.05,0.0,-0.05,-0.3,0.0,-0.3,-0.05,1.0,-0.05,0.2,1.0,0.2,-0.05,1.0,-0.05,-0.3,1.0,-0.3,-0.3,0.5,-0.3,0.2,0.5,0.2,0.2,0.5,0.2,-0.3,0.5,-0.05,0.7,0.0,0.2,0.45,0.0,-0.3,0.45,0.0,-0.05,0.7,1.0,0.2,0.45,1.0,-0.3,0.45,1.0,-0.3,0.7,0.5,0.2,0.7,0.5,-0.3,-0.05,2.0,-0.05,0.2,2.0,0.2,-0.05,2.0,-0.05,-0.3,2.0,-0.3,-0.3,1.5,-0.3,0.2,1.5,0.2,0.2,1.5,0.2,-0.3,1.5,-0.05,0.7,2.0,0.2,0.45,2.0,-0.3,0.45,2.0,-0.3,0.7,1.5,0.2,0.7,1.5,-0.05,-0.05,0.0,-0.3,-0.05,0.5,-0.05,0.2,0.5,0.2,-0.05,0.5,-0.05,-0.05,1.0,-0.05,0.45,0.0,-0.05,0.7,0.5,0.2,0.45,0.5,-0.05,0.45,1.0,-0.3,-0.05,1.5,-0.05,0.2,1.5,0.2,-0.05,1.5,-0.05,-0.05,2.0,-0.05,0.7,1.5,0.2,0.45,1.5,-0.05,0.45,2.0,-0.05,-0.05,0.5,-0.05,0.45,0.5,-0.05,-0.05,1.5,-0.05,0.45,1.5],71,3)
+ self.assertTrue(m3D.getCoords().isEqual(coordsExp2,1e-14))
+ self.assertTrue(m3D.getNodalConnectivity().isEqual(DataArrayInt([27,0,2,3,1,6,8,9,7,18,19,20,21,22,23,24,25,26,27,28,29,51,52,53,54,55,51,67,27,4,5,3,2,10,11,9,8,30,31,19,32,33,34,23,35,36,37,28,27,56,57,58,53,59,56,68,27,6,8,9,7,12,14,15,13,22,23,24,25,38,39,40,41,42,43,44,45,55,60,61,62,63,55,69,27,10,11,9,8,16,17,15,14,33,34,23,35,46,47,39,48,49,50,44,43,59,64,65,61,66,59,70])))
+ self.assertTrue(m3D.getNodalConnectivityIndex().isEqual(DataArrayInt([0,28,56,84,112])))
+ pass
+
+ def testSwig2GaussNEIntegral1(self):
+ m2D=MEDCouplingDataForTest.build2DTargetMesh_1()
+ m0=m2D[0] ; m0.zipCoords()
+ m1=m2D[[1,2]] ; m1.zipCoords()
+ m2=m2D[[3,4]] ; m2.zipCoords()
+ m0.convertLinearCellsToQuadratic(1)
+ m1.convertLinearCellsToQuadratic(0)
+ m2.convertLinearCellsToQuadratic(1)
+ m=MEDCouplingUMesh.MergeUMeshes([m0,m1,m2])
+ m.mergeNodes(1e-12)
+ f=MEDCouplingFieldDouble(ON_GAUSS_NE)
+ f.setMesh(m)
+ arr=DataArrayDouble([1.1,2.2,3.3,4.4,5.5,6.6,7.7,8.8,9.9,
+ 11.1,12.2,13.3,14.4,15.5,16.6,
+ 21.1,22.2,23.3,24.4,25.5,26.6,
+ 31.1,32.2,33.3,34.4,35.5,36.6,37.7,38.8,39.9,
+ 41.1,42.2,43.3,44.4,45.5,46.6,47.7,48.8,49.9])
+ arr2=DataArrayDouble(len(arr),2)
+ arr2[:,0]=arr ; arr2[:,1]=arr+100
+ f.setArray(arr2)
+ f.checkCoherency()
+ res=f.integral(False)
+ # a=25./81 ; b=40./81 ; c=64./81
+ # p1=0.11169079483905 ; p2=0.0549758718227661
+ # 1st compo
+ # c0=(a*(1.1+2.2+3.3+4.4)+b*(5.5+6.6+7.7+8.8)+c*9.9)*0.25/3.9999999999999978 ; c0=1.5837962962962973
+ # c1=(p2*(11.1+12.2+13.3)+p1*(14.4+15.5+16.6))*0.125/0.4999999999854482 ; c1=1.8014347172346943
+ # c2=(p2*(21.1+22.2+23.3)+p1*(24.4+25.5+26.6))*0.125/0.4999999999854482 ; c2=3.0514347172346943
+ # c3=(a*(31.1+32.2+33.3+34.4)+b*(35.5+36.6+37.7+38.8)+c*39.9)*0.25/3.9999999999999978 ; c3=9.0837962962963
+ # c4=(a*(41.1+42.2+43.3+44.4)+b*(45.5+46.6+47.7+48.8)+c*49.9)*0.25/3.9999999999999978 ; c4=11.583796296296303
+ # c0+c1+c2+c3+c4=27.104258323358287
+ integExp0=27.104258323358287
+ self.assertAlmostEqual(res[0],integExp0,13)
+ # 2nd compo
+ # c0=(a*(101.1+102.2+103.3+104.4)+b*(105.5+106.6+107.7+108.8)+c*109.9)*0.25/3.9999999999999978 ; c0=26.58379629629631
+ # c1=(p2*(111.1+112.2+113.3)+p1*(114.4+115.5+116.6))*0.125/0.4999999999854482 ; c1=14.301434717234699
+ # c2=(p2*(121.1+122.2+123.3)+p1*(124.4+125.5+126.6))*0.125/0.4999999999854482 ; c2=15.5514347172347
+ # c3=(a*(131.1+132.2+133.3+134.4)+b*(135.5+136.6+137.7+138.8)+c*139.9)*0.25/3.9999999999999978 ; c3=34.08379629629631
+ # c4=(a*(141.1+142.2+143.3+144.4)+b*(145.5+146.6+147.7+148.8)+c*149.9)*0.25/3.9999999999999978 ; c4=36.58379629629632
+ # c0+c1+c2+c3+c4=127.10425832335835
+ integExp1=127.10425832335835
+ self.assertAlmostEqual(res[1],integExp1,12)
+ meas=f.getDiscretization().getMeasureField(f.getMesh(),False)
+ intPerTuple=meas*f
+ res2=intPerTuple.accumulate()
+ self.assertAlmostEqual(res2[0],integExp0,13)
+ self.assertAlmostEqual(res2[1],integExp1,12)
+ #
+ meas2=f.buildMeasureField(False)
+ intPerTuple=meas2*f
+ res3=intPerTuple.accumulate()
+ self.assertAlmostEqual(res3[0],integExp0,13)
+ self.assertAlmostEqual(res3[1],integExp1,12)
+ #
+ res4=f.getWeightedAverageValue(False) # res4==res2 because sum of area of mesh is equal to 1
+ self.assertAlmostEqual(res4[0],integExp0,13)
+ self.assertAlmostEqual(res4[1],integExp1,12)
+ #
+ m.scale([0,0],2.)
+ #
+ res5=f.getWeightedAverageValue() # res4==res4 because weighted average is not sensitive to the scaling
+ self.assertAlmostEqual(res5[0],integExp0,13)
+ self.assertAlmostEqual(res5[1],integExp1,12)
+ meas3=f.buildMeasureField(False)
+ delta=4*meas2.getArray()-meas3.getArray()
+ delta.abs()
+ self.assertTrue(delta.isUniform(0.,1e-16))
+ res6=f.integral(False)
+ self.assertAlmostEqual(res6[0],4.*integExp0,12)
+ self.assertAlmostEqual(res6[1],4.*integExp1,11)
+ pass
+
def setUp(self):
pass
pass
%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getOffsetArr;
%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::clone;
%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::clonePart;
+%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getMeasureField;
+%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getOffsetArr;
+%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getLocalizationOfDiscValues;
+%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getValueOnMulti;
+%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::computeTupleIdsToSelectFromCellIds;
+%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::buildSubMeshData;
%newobject ParaMEDMEM::MEDCouplingField::buildMeasureField;
%newobject ParaMEDMEM::MEDCouplingField::getLocalizationOfDiscr;
%newobject ParaMEDMEM::MEDCouplingField::computeTupleIdsToSelectFromCellIds;
%newobject ParaMEDMEM::DataArrayInt::duplicateEachTupleNTimes;
%newobject ParaMEDMEM::DataArrayInt::buildPermutationArr;
%newobject ParaMEDMEM::DataArrayInt::buildPermArrPerLevel;
+%newobject ParaMEDMEM::DataArrayInt::getDifferentValues;
%newobject ParaMEDMEM::DataArrayInt::__neg__;
%newobject ParaMEDMEM::DataArrayInt::__add__;
%newobject ParaMEDMEM::DataArrayInt::__radd__;
%newobject ParaMEDMEM::DataArrayDouble::fromCylToCart;
%newobject ParaMEDMEM::DataArrayDouble::fromSpherToCart;
%newobject ParaMEDMEM::DataArrayDouble::getDifferentValues;
+%newobject ParaMEDMEM::DataArrayDouble::findClosestTupleId;
%newobject ParaMEDMEM::DataArrayDouble::duplicateEachTupleNTimes;
%newobject ParaMEDMEM::DataArrayDouble::__neg__;
%newobject ParaMEDMEM::DataArrayDouble::__add__;
%extend ParaMEDMEM::DataArrayInt
{
- PyObject *getDifferentValues() const throw(INTERP_KERNEL::Exception)
+ void pushBackValsSilent(PyObject *li) throw(INTERP_KERNEL::Exception)
{
- std::set<int> ret=self->getDifferentValues();
- return convertIntArrToPyList3(ret);
+ int szArr,sw,iTypppArr;
+ std::vector<int> stdvecTyyppArr;
+ const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr);
+ self->pushBackValsSilent(tmp,tmp+szArr);
}
PyObject *partitionByDifferentValues() const throw(INTERP_KERNEL::Exception)
}
%ignore ParaMEDMEM::DataArray::getInfoOnComponents;
-%ignore ParaMEDMEM::DataArrayInt::getDifferentValues;
%ignore ParaMEDMEM::DataArrayInt::partitionByDifferentValues;
%ignore ParaMEDMEM::MEDCouplingFieldDiscretizationPerCell::getArrayOfDiscIds;
%ignore ParaMEDMEM::MEDCouplingFieldDiscretization::clonePart;
%include "NormalizedUnstructuredMesh.hxx"
%include "MEDCouplingNatureOfField.hxx"
%include "MEDCouplingTimeDiscretization.hxx"
-%include "MEDCouplingFieldDiscretization.hxx"
%include "MEDCouplingGaussLocalization.hxx"
+%include "MEDCouplingFieldDiscretization.hxx"
namespace ParaMEDMEM
{
return ParaMEDMEM_DataArrayDouble_New__SWIG_1(elt0,nbOfTuples,elt2);
}
+ void pushBackValsSilent(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ double val;
+ std::vector<double> bb;
+ int sw,nbTuples=-1;
+ const char msg[]="Python wrap of DataArrayDouble::pushBackValsSilent : ";
+ const double *tmp=convertObjToPossibleCpp5_SingleCompo(li,sw,val,bb,msg,true,nbTuples);
+ self->pushBackValsSilent(tmp,tmp+nbTuples);
+ }
+
std::string __str__() const
{
return self->repr();
}
}
+ PyObject *minimalDistanceTo(const DataArrayDouble *other) const throw(INTERP_KERNEL::Exception)
+ {
+ int thisTupleId,otherTupleId;
+ double r0=self->minimalDistanceTo(other,thisTupleId,otherTupleId);
+ PyObject *ret=PyTuple_New(3);
+ PyTuple_SetItem(ret,0,PyFloat_FromDouble(r0));
+ PyTuple_SetItem(ret,1,PyInt_FromLong(thisTupleId));
+ PyTuple_SetItem(ret,2,PyInt_FromLong(otherTupleId));
+ return ret;
+ }
+
PyObject *getMaxValue() const throw(INTERP_KERNEL::Exception)
{
int tmp;
{
public:
static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME);
- static MEDCouplingFieldDouble *New(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td=ONE_TIME);
+ static MEDCouplingFieldDouble *New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME);
void setTimeUnit(const char *unit);
const char *getTimeUnit() const;
void synchronizeTimeWithSupport() throw(INTERP_KERNEL::Exception);
double getAverageValue() const throw(INTERP_KERNEL::Exception);
double norm2() const throw(INTERP_KERNEL::Exception);
double normMax() const throw(INTERP_KERNEL::Exception);
- double getWeightedAverageValue() const throw(INTERP_KERNEL::Exception);
+ //do not put a default value to isWAbs because confusion in python with overloaded getWeightedAverageValue method
+ double getWeightedAverageValue(int compId, bool isWAbs) const throw(INTERP_KERNEL::Exception);
double integral(int compId, bool isWAbs) const throw(INTERP_KERNEL::Exception);
double normL1(int compId) const throw(INTERP_KERNEL::Exception);
double normL2(int compId) const throw(INTERP_KERNEL::Exception);
return MEDCouplingFieldDouble::New(type,td);
}
- MEDCouplingFieldDouble(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td=ONE_TIME)
+ MEDCouplingFieldDouble(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME)
{
return MEDCouplingFieldDouble::New(ft,td);
}
int sz=self->getNumberOfComponents();
INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
self->accumulate(tmp);
- PyObject *ret=convertDblArrToPyList(tmp,sz);
- return ret;
+ return convertDblArrToPyList(tmp,sz);
}
PyObject *integral(bool isWAbs) const throw(INTERP_KERNEL::Exception)
{
int sz=self->getNumberOfComponents();
INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
self->integral(isWAbs,tmp);
- PyObject *ret=convertDblArrToPyList(tmp,sz);
- return ret;
+ return convertDblArrToPyList(tmp,sz);
+ }
+ PyObject *getWeightedAverageValue(bool isWAbs=true) const throw(INTERP_KERNEL::Exception)
+ {
+ int sz=self->getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
+ self->getWeightedAverageValue(tmp,isWAbs);
+ return convertDblArrToPyList(tmp,sz);
}
PyObject *normL1() const throw(INTERP_KERNEL::Exception)
{
int sz=self->getNumberOfComponents();
INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
self->normL1(tmp);
- PyObject *ret=convertDblArrToPyList(tmp,sz);
- return ret;
+ return convertDblArrToPyList(tmp,sz);
}
PyObject *normL2() const throw(INTERP_KERNEL::Exception)
{
int sz=self->getNumberOfComponents();
INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
self->normL2(tmp);
- PyObject *ret=convertDblArrToPyList(tmp,sz);
- return ret;
+ return convertDblArrToPyList(tmp,sz);
}
void renumberCells(PyObject *li, bool check=true) throw(INTERP_KERNEL::Exception)
{
class MEDCouplingFieldTemplate : public ParaMEDMEM::MEDCouplingField
{
public:
- static MEDCouplingFieldTemplate *New(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldTemplate *New(const MEDCouplingFieldDouble& f) throw(INTERP_KERNEL::Exception);
static MEDCouplingFieldTemplate *New(TypeOfField type);
std::string simpleRepr() const throw(INTERP_KERNEL::Exception);
std::string advancedRepr() const throw(INTERP_KERNEL::Exception);
void updateTime() const;
%extend
{
- MEDCouplingFieldTemplate(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception)
+ MEDCouplingFieldTemplate(const MEDCouplingFieldDouble& f) throw(INTERP_KERNEL::Exception)
{
return MEDCouplingFieldTemplate::New(f);
}
mesh2.insertNextCell(NORM_QUAD4,4,conn2[16:20])
mesh2.finishInsertingCells();
return [mesh,mesh2]
+
+ def buildFieldOnGauss_1(self):
+ coo=DataArrayDouble([1.0,0.0,1.33333333333333,0.0,1.66666666666667,0.0,0.923879532511287,0.38268343236509006,1.23183937668172,0.510244576486786,1.53979922085214,0.6378057206084831,2.0,0.0,1.8477590650225701,0.7653668647301801,0.9428090415820631,0.9428090415820631,1.1785113019775801,1.1785113019775801,1.4142135623731,1.41421356237309,0.707106781186548,0.707106781186547,0.38268343236509006,0.923879532511287,0.510244576486786,1.23183937668172,0.6378057206084831,1.53979922085214,0.7653668647301801,1.8477590650225701,3.1550283219328204e-17,1.33333333333333,1.16009632455949e-17,1.66666666666667,-2.7620050344068196e-16,2.0,-1.3810025172034098e-16,1.0,-2.0,0.0,-1.53979922085214,0.6378057206084831,-1.66666666666667,0.0,-1.33333333333333,0.0,-0.923879532511287,0.38268343236509006,-1.8477590650225701,0.7653668647301801,-0.9428090415820631,0.9428090415820631,-1.23183937668172,0.510244576486786,-1.83333333333333,0.0,-1.6937791429373599,0.701586292669331,-1.5,0.0,-1.30771370720431,0.26012042935483803,-1.16666666666667,0.0,-1.0778594545965,0.44646400442593803,-1.38578268717091,0.9259503883660041,-1.38581929876693,0.574025148547635,-1.06066017177982,1.06066017177982,-0.8314696123025451,0.5555702330196021,-1.0,0.0,-1.1785113019775801,1.1785113019775801,-0.707106781186548,0.707106781186547,-1.63464213400538,0.325150536693547,-1.9615705608064598,0.390180644032256,-1.47117792060485,0.292635483024192,-0.9807852804032301,0.19509032201612803,-1.524360955888,1.0185454272026,-1.2963624321753402,1.2963624321753402,-1.10862614973673,0.740760310692803,-0.970047881019636,0.6481652718562021,-0.824957911384305,0.824957911384305,-1.4142135623731,1.41421356237309,-1.7981063474059198,0.357665590362902,-1.1442494938037702,0.227605375685483,-1.66293922460509,1.1111404660392,-1.24720441845382,0.833355349529403,-0.7653668647301801,1.8477590650225701,-0.6378057206084831,1.53979922085214,-0.510244576486786,1.23183937668172,-0.701586292669331,1.6937791429373599,-0.574025148547635,1.38581929876693,-0.44646400442593803,1.0778594545965,-0.38268343236509006,0.923879532511287,-0.9259503883660041,1.38578268717091,-0.740760310692803,1.10862614973673,-0.5555702330196021,0.8314696123025451,-0.325150536693547,1.63464213400538,-0.26012042935483803,1.30771370720431,-0.19509032201612803,0.9807852804032301,1.6805133673525298e-18,1.83333333333333,-2.4643915380595496e-16,1.5,-1.4799359654427099e-16,1.16666666666667,-1.1111404660392,1.66293922460509,-0.39018064403225705,1.9615705608064598],73,2)
+ coo.setInfoOnComponents(["X [INCONNUE]","Y [INCONNUE]"])
+ m=MEDCouplingUMesh("MA1",2)
+ m.setDescription("CREE PAR CODE_ASTER") ; m.setTimeUnit("SANS UNITES") ; m.setTime(-1.,-1,-1)
+ m.setCoords(coo)
+ m.allocateCells(0)
+ conn=[[0,1,4,3],[1,2,5,4],[2,6,7,5],[3,4,8,11],[4,5,9,8],[5,7,10,9],[20,22,21,28,41,51],[21,25,20,29,42,51],[22,23,21,30,43,41],[23,27,21,31,35,43],[23,38,24,32,44,52],[24,27,23,33,31,52],[25,21,50,29,45,53],[21,39,50,34,46,45],[21,27,26,35,47,54],[26,39,21,36,34,54],[27,24,26,33,48,47],[24,40,26,37,49,48],[50,39,56,55,46,62,58,71],[39,26,57,56,36,63,59,62],[26,40,61,57,49,64,60,63],[55,56,17,18,58,65,68,72],[56,57,16,17,59,66,69,65],[57,61,19,16,60,67,70,66]]
+ for i in xrange(0,6):
+ m.insertNextCell(NORM_QUAD4,conn[i])
+ pass
+ for i in xrange(6,18):
+ m.insertNextCell(NORM_TRI6,conn[i])
+ pass
+ for i in xrange(18,24):
+ m.insertNextCell(NORM_QUAD8,conn[i])
+ pass
+ fff=MEDCouplingFieldDouble.New(ON_GAUSS_PT) ; fff.setName("CH13") ; fff.setNature(ConservativeVolumic)
+ fff.setMesh(m)
+ fff.setGaussLocalizationOnCells(range(0,6),[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[-0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626],[1.,1.,1.,1.])
+ fff.setGaussLocalizationOnCells(range(6,18),[0.,0.,1.,0.,0.,1.,0.5, 0.,0.5, 0.5, 0.,0.5],[0.16666666666666666,0.16666666666666666,0.6666666666666666,0.16666666666666666,0.16666666666666666,0.6666666666666666],[0.16666666666666666,0.16666666666666666,0.16666666666666666])
+ fff.setGaussLocalizationOnCells(range(18,24),[-1.,-1.,1.,-1.,1.,1.,-1.,1.,0.,-1.,1.,0.,0.,1.,-1.,0.],[-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.0,-0.774596669241483,0.774596669241483,0.0,0.0,0.774596669241483,-0.774596669241483,0.0,0.0,0.0],[0.30864197530864196,0.30864197530864196,0.30864197530864196,0.30864197530864196,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.7901234567901234])
+ return fff
+
+ def buildFieldOnGauss_2(self):
+ coo=DataArrayDouble([1.0,0.0,1.24068268955165,0.15233667925643402,1.25,0.0,1.5,0.0,1.73695576537231,0.21327135095900804,1.75,0.0,2.0,0.0,0.9925461516413221,0.12186934340514702,1.212869657845,0.302402369499585,1.48881922746198,0.182804015107721,1.6980175209829897,0.423363317299419,1.9850923032826397,0.243738686810295,0.9702957262759959,0.241921895599668,1.1669755331215,0.447959936931625,1.4554435894139899,0.362882843399502,1.6337657463701,0.627143911704275,1.94059145255199,0.483843791199335,0.9335804264972021,0.35836794954530005,1.10368449107366,0.586839453482364,1.4003706397458,0.5375519243179501,1.5451582875031202,0.8215752348753091,1.8671608529944002,0.716735899090601,0.882947592858927,0.46947156278589103,1.02394005536124,0.716970545438808,1.32442138928839,0.704207344178836,1.43351607750574,1.00375876361433,1.76589518571785,0.9389431255717821,1.125,0.0,1.11661442059649,0.137103011330791,1.375,0.0,1.4972021976328,0.09157280930228531,1.625,0.0,1.61288749641715,0.198037683033365,1.875,0.0,1.9962695968437298,0.12209707906971401,1.0915826920605,0.272162132549626,1.36475095850682,0.167570347182078,1.47488236134593,0.27335328823822097,1.5767305551984903,0.39312308034946003,1.8610240343274802,0.228505018884652,1.96650981512791,0.364471050984295,1.05027797980935,0.403163943238463,1.3341566236295,0.332642606449543,1.43057542612234,0.45105869925641007,1.5170681930579497,0.5823479180111131,1.8193044867674901,0.45360355424937704,1.9074339014964499,0.601411599008546,0.993316041966293,0.528155508134127,1.28367308643365,0.492755930624788,1.36494190631481,0.6220398639843591,1.43478983839576,0.7628912895270731,1.7504632996822498,0.671939905397438,1.81992254175309,0.8293864853124782,0.921546049825116,0.645273490894927,1.21405294018102,0.6455233988306001,1.27896024653114,0.783747847073923,1.33112207196961,0.93206170907045,1.65552673661049,0.8802591802235451,1.70528032870818,1.0449971294319,0.8191520442889921,0.5735764363510459,1.22872806643349,0.8603646545265691,1.6383040885779798,1.14715287270209,1.24766849802733,0.0763106744185711,0.9981347984218671,0.0610485395348569,1.37243534783007,0.0839417418604282,1.74673589723827,0.106834944186,1.871502747041,0.114466011627857,1.22906863445494,0.227794406865184,0.9832549075639551,0.18223552549214703,1.3519754979004401,0.25057384755170303,1.7206960882369198,0.318912169611258,1.84360295168241,0.341691610297777,1.19214618843528,0.37588224938034104,0.953716950748227,0.300705799504273,1.31136080727881,0.413470474318376,1.6690046638094,0.526235149132478,1.7882192826529297,0.563823374070512,1.13745158859568,0.518366553320299,0.9099612708765431,0.4146932426562391,1.25119674745525,0.570203208652329,1.5924322240339497,0.725713174648418,1.7061773828935198,0.777549829980448,1.06580020544262,0.6531232058949361,0.8526401643540921,0.522498564715949,1.17238022598688,0.7184355264844301,1.12633406089736,0.7886675999826881,1.49212028761966,0.91437248825291,1.59870030816392,0.979684808842404,1.53591008304186,1.07545581815821,1.1229016482246,0.068679606976714,1.6219690474355302,0.0992038767441424,1.10616177100945,0.205014966178666,1.59778922479143,0.29613272892474,1.07293156959176,0.338294024442307,1.5497900449658701,0.488646924194444,1.02370642973611,0.466529897988269,1.47868706517438,0.673876519316388,0.9592201848983541,0.587810885305442,1.3855402670754,0.8490601676634171,0.743144825477394,0.669130606358858,0.9289310318467431,0.836413257948573,1.11471723821609,1.00369590953829,1.30050344458544,1.170978561128,0.656059028990507,0.7547095802227721,0.820073786238134,0.943386975278465,0.984088543485761,1.13206437033416,1.14810330073339,1.32074176538985,0.559192903470747,0.8290375725550421,0.6989911293384331,1.0362969656938,0.8387893552061201,1.24355635883256,0.978587581073807,1.45081575197132,0.453990499739547,0.8910065241883681,0.567488124674433,1.11375815523546,0.6809857496093201,1.3365097862825501,0.794483374544207,1.55926141732964,0.8360379286620679,0.7527719321537151,1.0218241350314199,0.92005458374343,1.20761034140077,1.08733723533314,1.39339654777011,1.25461988692286,0.7380664076143211,0.8490482777506181,0.902081164861948,1.03772567280631,1.06609592210957,1.226403067862,1.2301106793572,1.4150804629177,0.6290920164045901,0.932667269124422,0.7688902422722771,1.13992666226318,0.9086884681399641,1.34718605540194,1.04848669400765,1.5544454485407,0.51073931220699,1.00238233971191,0.624236937141877,1.22513397075901,0.737734562076764,1.4478856018061,0.85123218701165,1.6706372328531902,1.48628965095479,1.33826121271772,1.31211805798101,1.5094191604455398,1.11838580694149,1.6580751451100801,0.907980999479094,1.7820130483767398,0.978260196065517,0.778143295797024,1.17391223527862,0.9337719549564292,1.36956427449172,1.08940061411583,1.56521631370483,1.24502927327524,0.876136580374814,0.891563061442727,1.05136389644978,1.06987567373127,1.22659121252474,1.2481882860198201,1.4018185285997,1.42650089830836,0.7609517862609011,0.991691675364044,0.913142143513081,1.19003001043685,1.06533250076526,1.38836834550966,1.21752285801744,1.5867066805824699,0.6344229537008801,1.07703645055191,0.7613075444410561,1.29244374066229,0.8881921351812321,1.50785103077267,1.01507672592141,1.7232583208830499,0.498436336156558,1.1463250929814,0.5981236033878691,1.37559011157769,0.697810870619181,1.60485513017397,0.7974981378504931,1.8341201487702499,0.42752517915708604,1.17461577598239,0.513030214988503,1.4095389311788602,0.59853525081992,1.6444620863753399,0.6840402866513371,1.87938524157182,0.38477266124137705,1.05715419838415,0.470277697072795,1.29207735358062,0.5557827329042121,1.5270005087771,0.6412877687356291,1.76192366397358,0.34202014332566905,0.9396926207859091,0.782608156852414,0.6225146366376201,0.7009092642998511,0.713250449154182,0.608761429008721,0.7933533402912349,0.507538362960704,0.861629160441526,0.398749068925246,0.917060074385124,-2.0,0.0,-1.75,0.0,-1.5,0.0,-1.25,0.0,-1.9632543668953297,0.38161799075309005,-1.71784757103341,0.333915741908953,-1.4724407751715,0.286213493064817,-1.22703397930958,0.23851124422068104,-1.85436770913357,0.749213186831824,-1.62257174549188,0.655561538477846,-1.39077578185018,0.561909890123868,-1.15897981820848,0.46825824176988995,-1.6773411358908499,1.08927807003005,-1.4676734939044902,0.953118311276297,-1.25800585191814,0.816958552522541,-1.04833820993178,0.680798793768784,-1.4386796006773,1.38931674091799,-1.25884465059264,1.21565214830325,-1.07900970050798,1.0419875556885,-0.8991747504233141,0.868322963073747,-1.0,0.0,-0.981627183447664,0.19080899537654503,-0.9271838545667871,0.374606593415912,-0.838670567945424,0.544639035015027,-0.7193398003386511,0.694658370458997,-1.00375876361433,1.43351607750574,-0.8603646545265691,1.22872806643349,-0.716970545438808,1.02394005536124,-0.5735764363510459,0.8191520442889921,-1.14715287270209,1.6383040885779798,-0.8134732861516011,1.8270909152852002,-0.71178912538265,1.59870455087455,-0.6101049646137,1.3703181864639,-0.50842080384475,1.14193182205325,-0.4067366430758,0.9135454576426011,-0.44990210868773,1.9487401295704703,-0.39366434510176407,1.70514761337416,-0.337426581515798,1.4615550971778501,-0.281188817929831,1.21796258098154,-0.224951054343865,0.974370064785235,-0.06979899340500181,1.9987816540381902,-0.0610741192293767,1.74893394728342,-0.0523492450537515,1.49908624052864,-0.0436243708781263,1.24923853377387,-0.03489949670250091,0.9993908270190961,0.312868930080462,1.97537668119028,0.27376031382040406,1.72845459604149,0.23465169756034704,1.48153251089271,0.19554308130028902,1.23461042574392,0.156434465040231,0.9876883405951381],219,2)
+ coo.setInfoOnComponents(["X [INCONNUE]","Y [INCONNUE]"])
+ m=MEDCouplingUMesh("MA2",2)
+ m.setDescription("CREE PAR CODE_ASTER") ; m.setTimeUnit("SANS UNITES") ; m.setTime(-1.,-1,-1)
+ m.setCoords(coo)
+ m.allocateCells(0)
+ conn=[[169,170,174,173],[170,171,175,174],[171,172,176,175],[172,189,190,176],[173,174,178,177],[174,175,179,178],[175,176,180,179],[176,190,191,180],[177,178,182,181],[178,179,183,182],[179,180,184,183],[180,191,192,184],[181,182,186,185],[182,183,187,186],[183,184,188,187],[184,192,193,188],[185,186,194,198],[186,187,195,194],[187,188,196,195],[188,193,197,196],[0,2,1,27,62,89],[1,7,0,28,63,89],[2,3,1,29,64,62],[3,9,1,30,36,64],[3,5,4,31,65,90],[4,9,3,32,30,90],[5,6,4,33,66,65],[6,11,4,34,39,66],[7,1,8,28,67,91],[8,12,7,35,68,91],[1,9,8,36,69,67],[9,14,8,37,42,69],[9,4,10,32,70,92],[10,14,9,38,37,92],[4,11,10,39,71,70],[11,16,10,40,45,71],[12,8,13,35,72,93],[13,17,12,41,73,93],[8,14,13,42,74,72],[14,19,13,43,48,74],[14,10,15,38,75,94],[15,19,14,44,43,94],[10,16,15,45,76,75],[16,21,15,46,51,76],[17,13,18,41,77,95],[18,22,17,47,78,95],[13,19,18,48,79,77],[19,24,18,49,54,79],[19,15,20,44,80,96],[20,24,19,50,49,96],[15,21,20,51,81,80],[21,26,20,52,57,81],[22,18,23,47,82,97],[23,59,22,53,83,97],[18,24,23,54,84,82],[24,60,23,55,85,84],[24,20,25,50,86,98],[25,60,24,56,55,98],[20,26,25,57,87,86],[26,61,25,58,88,87],[59,23,100,99,53,135,115,164],[23,60,101,100,85,136,116,135],[60,25,102,101,56,137,117,136],[25,61,131,102,88,138,118,137],[99,100,104,103,115,139,119,165],[100,101,105,104,116,140,120,139],[101,102,106,105,117,141,121,140],[102,131,132,106,118,142,122,141],[103,104,108,107,119,143,123,166],[104,105,109,108,120,144,124,143],[105,106,110,109,121,145,125,144],[106,132,133,110,122,146,126,145],[107,108,112,111,123,147,127,167],[108,109,113,112,124,148,128,147],[109,110,114,113,125,149,129,148],[110,133,134,114,126,150,130,149],[111,112,155,163,127,151,159,168],[112,113,156,155,128,152,160,151],[113,114,157,156,129,153,161,152],[114,134,158,157,130,154,162,153]]
+ for i in xrange(0,20):
+ m.insertNextCell(NORM_QUAD4,conn[i])
+ pass
+ for i in xrange(20,60):
+ m.insertNextCell(NORM_TRI6,conn[i])
+ pass
+ for i in xrange(60,80):
+ m.insertNextCell(NORM_QUAD8,conn[i])
+ pass
+ fff=MEDCouplingFieldDouble.New(ON_GAUSS_PT) ; fff.setName("CH23") ; fff.setNature(NoNature)
+ fff.setMesh(m)
+ fff.setGaussLocalizationOnCells(range(0,20),[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[-0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626],[1.,1.,1.,1.])
+ fff.setGaussLocalizationOnCells(range(20,60),[0.,0.,1.,0.,0.,1.,0.5, 0.,0.5, 0.5, 0.,0.5],[0.16666666666666666,0.16666666666666666,0.6666666666666666,0.16666666666666666,0.16666666666666666,0.6666666666666666],[0.16666666666666666,0.16666666666666666,0.16666666666666666])
+ fff.setGaussLocalizationOnCells(range(60,80),[-1.,-1.,1.,-1.,1.,1.,-1.,1.,0.,-1.,1.,0.,0.,1.,-1.,0.],[-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.0,-0.774596669241483,0.774596669241483,0.0,0.0,0.774596669241483,-0.774596669241483,0.0,0.0,0.0],[0.30864197530864196,0.30864197530864196,0.30864197530864196,0.30864197530864196,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.7901234567901234])
+ return fff
build2DTargetMesh_1=classmethod(build2DTargetMesh_1)
build2DSourceMesh_1=classmethod(build2DSourceMesh_1)
buildCoordsForMultiTypes_1=classmethod(buildCoordsForMultiTypes_1)
buildHexa8Mesh_1=classmethod(buildHexa8Mesh_1)
buildPointe_1=classmethod(buildPointe_1)
+ buildFieldOnGauss_1=classmethod(buildFieldOnGauss_1)
+ buildFieldOnGauss_2=classmethod(buildFieldOnGauss_2)
pass
import unittest
class MEDCouplingBasicsTest(unittest.TestCase):
+ def testExample_DataArrayInt_(self):
+#! [PySnippet_DataArrayInt__1]
+ pass
+
+ def testExample_DataArrayInt_getTuple(self):
+#! [Snippet_DataArrayInt_getTuple_1]
+ dv=DataArrayInt.New();
+ dv.alloc( 6, 1 )
+ dv.iota(7)
+ dv.rearrange( 2 )
+ print dv.getTuple( 1 )
+#! [Snippet_DataArrayInt_getTuple_1]
+#! [Snippet_DataArrayInt_getTuple_2]
+ for tpl in dv:
+ print tpl
+#! [Snippet_DataArrayInt_getTuple_2]
+ pass
+
+ def testExample_DataArrayInt_buildPermutationArr(self):
+#! [PySnippet_DataArrayInt_buildPermutationArr_1]
+ a=DataArrayInt.New()
+ a.setValues([4,5,6,7,8],5,1)
+ b=DataArrayInt.New()
+ b.setValues([5,4,8,6,7],5,1)
+ c=a.buildPermutationArr(b)
+#! [PySnippet_DataArrayInt_buildPermutationArr_1]
+ self.assertEqual([1,0,4,2,3],c.getValues())
+ pass
+
+ def testExample_DataArrayInt_invertArrayO2N2N2O(self):
+#! [PySnippet_DataArrayInt_invertArrayO2N2N2O_1]
+ arr1=[2,0,4,1,5,3]
+ da=DataArrayInt.New();
+ da.setValues(arr1,6,1);
+ da2=da.invertArrayO2N2N2O(6);
+ expected1=[1,3,0,5,2,4]
+ for i in xrange(6):
+ self.assertEqual(expected1[i],da2.getIJ(i,0));
+ pass
+#! [PySnippet_DataArrayInt_invertArrayO2N2N2O_1]
+ pass
+
+ def testExample_DataArrayInt_invertArrayN2O2O2N(self):
+#! [PySnippet_DataArrayInt_invertArrayN2O2O2N_1]
+ arr1=[2,0,4,1,5,3]
+ da=DataArrayInt.New();
+ da.setValues(arr1,6,1);
+ da2=da.invertArrayN2O2O2N(7);
+ expected1=[1,3,0,5,2,4,-1]
+ for i in xrange(6):
+ self.assertEqual(expected1[i],da2.getIJ(i,0));
+ pass
+#! [PySnippet_DataArrayInt_invertArrayN2O2O2N_1]
+ pass
+
+
+ def testExample_DataArrayDouble_getIdsInRange(self):
+#! [PySnippet_DataArrayDouble_getIdsInRange_1]
+ da=DataArrayDouble.New()
+ da.alloc( 10, 1 )
+ da[ :, :] = range(10)
+ da2 = da.getIdsInRange( 2.5, 6 )
+#! [PySnippet_DataArrayDouble_getIdsInRange_1]
+ pass
+
+ def testExample_DataArrayDouble_setPartOfValues2(self):
+#! [Snippet_DataArrayDouble_setPartOfValues2_1]
+ da=DataArrayDouble.New()
+ da.alloc( 4, 7 )
+ #
+ dv=DataArrayDouble.New();
+ dv.alloc( 6, 1 )
+ dv.iota(7)
+ dv.rearrange( 2 )
+#! [Snippet_DataArrayDouble_setPartOfValues2_1]
+#! [Snippet_DataArrayDouble_setPartOfValues2_2]
+ da.fillWithZero()
+ da[ [0,1,2], [1,3] ] = dv
+#! [Snippet_DataArrayDouble_setPartOfValues2_2]
+#! [Snippet_DataArrayDouble_setPartOfValues2_3]
+ da.fillWithZero()
+ dv.rearrange( 6 )
+ da[ [0,2,3], [0,2,3,4,5,6]] = dv
+#! [Snippet_DataArrayDouble_setPartOfValues2_3]
+ pass
+
+ def testExample_DataArrayInt_setPartOfValues2(self):
+#! [Snippet_DataArrayInt_setPartOfValues2_1]
+ da=DataArrayInt.New()
+ da.alloc( 4, 7 )
+ #
+ dv=DataArrayInt.New();
+ dv.alloc( 6, 1 )
+ dv.iota(7)
+ dv.rearrange( 2 )
+#! [Snippet_DataArrayInt_setPartOfValues2_1]
+#! [Snippet_DataArrayInt_setPartOfValues2_2]
+ da.fillWithZero()
+ da[ [0,1,2], [1,3] ] = dv
+#! [Snippet_DataArrayInt_setPartOfValues2_2]
+#! [Snippet_DataArrayInt_setPartOfValues2_3]
+ da.fillWithZero()
+ dv.rearrange( 6 )
+ da[ [0,2,3], [0,2,3,4,5,6]] = dv
+#! [Snippet_DataArrayInt_setPartOfValues2_3]
+ pass
+
+ def testExample_DataArrayDouble_setPartOfValues3(self):
+#! [Snippet_DataArrayDouble_setPartOfValues3_1]
+ da=DataArrayDouble.New()
+ da.alloc( 4, 7 )
+ #
+ dv=DataArrayDouble.New();
+ dv.alloc( 6, 1 )
+ dv.iota(7)
+ dv.rearrange( 2 )
+#! [Snippet_DataArrayDouble_setPartOfValues3_1]
+#! [Snippet_DataArrayDouble_setPartOfValues3_2]
+ da.fillWithZero()
+ da[ 0:3, [1,3] ] = dv
+#! [Snippet_DataArrayDouble_setPartOfValues3_2]
+#! [Snippet_DataArrayDouble_setPartOfValues3_3]
+ da.fillWithZero()
+ dv.rearrange( 6 )
+ da[ 0:4:2, [0,2,3,4,5,6]] = dv
+#! [Snippet_DataArrayDouble_setPartOfValues3_3]
+ pass
+
+ def testExample_DataArrayInt_setPartOfValues3(self):
+#! [Snippet_DataArrayInt_setPartOfValues3_1]
+ da=DataArrayInt.New()
+ da.alloc( 4, 7 )
+ #
+ dv=DataArrayInt.New();
+ dv.alloc( 6, 1 )
+ dv.iota(7)
+ dv.rearrange( 2 )
+#! [Snippet_DataArrayInt_setPartOfValues3_1]
+#! [Snippet_DataArrayInt_setPartOfValues3_2]
+ da.fillWithZero()
+ da[ 0:3, [1,3] ] = dv
+#! [Snippet_DataArrayInt_setPartOfValues3_2]
+#! [Snippet_DataArrayInt_setPartOfValues3_3]
+ da.fillWithZero()
+ dv.rearrange( 6 )
+ da[ 0:4:2, [0,2,3,4,5,6]] = dv
+#! [Snippet_DataArrayInt_setPartOfValues3_3]
+ pass
+
+ def testExample_DataArrayDouble_setPartOfValues1(self):
+#! [Snippet_DataArrayDouble_setPartOfValues1_1]
+ da=DataArrayDouble.New()
+ da.alloc( 4, 4 )
+ da.setInfoOnComponents( ["v1","v2","v3","v4"])
+ #
+ dv=DataArrayDouble.New();
+ dv.alloc( 4, 1 )
+ dv.iota(7)
+ dv.rearrange( 2 )
+ dv.setInfoOnComponents( ["a1","a2"])
+#! [Snippet_DataArrayDouble_setPartOfValues1_1]
+#! [Snippet_DataArrayDouble_setPartOfValues1_2]
+ da.fillWithZero()
+ da.setPartOfValues1( dv, 1,3,1, 1,3,1, True )
+#! [Snippet_DataArrayDouble_setPartOfValues1_2]
+#! [Snippet_DataArrayDouble_setPartOfValues1_3]
+ da.fillWithZero()
+ da.setPartOfValues1( dv, 0,4,1, 1,2,1, False )
+#! [Snippet_DataArrayDouble_setPartOfValues1_3]
+#! [Snippet_DataArrayDouble_setPartOfValues1_4]
+ da.fillWithZero()
+ da.setPartOfValues1( dv, 1,2,1, 0,4,1, False )
+#! [Snippet_DataArrayDouble_setPartOfValues1_4]
+#! [Snippet_DataArrayDouble_setPartOfValues1_5]
+ da.fillWithZero()
+ da.setPartOfValues1( dv, 0,3,2, 1,4,2, True )
+#! [Snippet_DataArrayDouble_setPartOfValues1_5]
+#! [Snippet_DataArrayDouble_setPartOfValues1_6]
+ da2 = da.deepCpy()
+ da2.fillWithZero()
+ da2[ 0:3:2, 1:4:2 ] = dv
+ self.assertTrue( da.isEqual( da2, 1e-20 ))
+#! [Snippet_DataArrayDouble_setPartOfValues1_6]
+ pass
+
+ def testExample_DataArrayInt_setPartOfValues1(self):
+#! [Snippet_DataArrayInt_setPartOfValues1_1]
+ da=DataArrayInt.New()
+ da.alloc( 4, 4 )
+ da.setInfoOnComponents( ["v1","v2","v3","v4"])
+ #
+ dv=DataArrayInt.New();
+ dv.alloc( 4, 1 )
+ dv.iota(7)
+ dv.rearrange( 2 )
+ dv.setInfoOnComponents( ["a1","a2"])
+#! [Snippet_DataArrayInt_setPartOfValues1_1]
+#! [Snippet_DataArrayInt_setPartOfValues1_2]
+ da.fillWithZero()
+ da.setPartOfValues1( dv, 1,3,1, 1,3,1, True )
+#! [Snippet_DataArrayInt_setPartOfValues1_2]
+#! [Snippet_DataArrayInt_setPartOfValues1_3]
+ da.fillWithZero()
+ da.setPartOfValues1( dv, 0,4,1, 1,2,1, False )
+#! [Snippet_DataArrayInt_setPartOfValues1_3]
+#! [Snippet_DataArrayInt_setPartOfValues1_4]
+ da.fillWithZero()
+ da.setPartOfValues1( dv, 1,2,1, 0,4,1, False )
+#! [Snippet_DataArrayInt_setPartOfValues1_4]
+#! [Snippet_DataArrayInt_setPartOfValues1_5]
+ da.fillWithZero()
+ da.setPartOfValues1( dv, 0,3,2, 1,4,2, True )
+#! [Snippet_DataArrayInt_setPartOfValues1_5]
+#! [Snippet_DataArrayInt_setPartOfValues1_6]
+ da2 = da.deepCpy()
+ da2.fillWithZero()
+ da2[ 0:3:2, 1:4:2 ] = dv
+ self.assertTrue( da.isEqual( da2 ))
+#! [Snippet_DataArrayInt_setPartOfValues1_6]
+ pass
+
+ def testExample_DataArrayDouble_setPartOfValuesSimple1(self):
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple1_1]
+ da=DataArrayDouble.New()
+ da.alloc( 4, 4 )
+ dv = 7
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple1_1]
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple1_2]
+ da.fillWithZero()
+ da.setPartOfValuesSimple1( dv, 1,3,1, 1,3,1 )
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple1_2]
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple1_3]
+ da.fillWithZero()
+ da.setPartOfValuesSimple1( dv, 0,4,1, 1,2,1 )
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple1_3]
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple1_4]
+ da.fillWithZero()
+ da.setPartOfValuesSimple1( dv, 1,2,1, 0,4,1 )
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple1_4]
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple1_5]
+ da.fillWithZero()
+ da.setPartOfValuesSimple1( dv, 0,3,2, 1,4,2 )
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple1_5]
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple1_6]
+ da2 = da.deepCpy()
+ da2.fillWithZero()
+ da2[ 0:3:2, 1:4:2 ] = dv
+ self.assertTrue( da.isEqual( da2, 1e-20 ))
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple1_6]
+ pass
+
+ def testExample_DataArrayInt_setPartOfValuesSimple1(self):
+#! [Snippet_DataArrayInt_setPartOfValuesSimple1_1]
+ da=DataArrayInt.New()
+ da.alloc( 4, 4 )
+ dv = 7
+#! [Snippet_DataArrayInt_setPartOfValuesSimple1_1]
+#! [Snippet_DataArrayInt_setPartOfValuesSimple1_2]
+ da.fillWithZero()
+ da.setPartOfValuesSimple1( dv, 1,3,1, 1,3,1 )
+#! [Snippet_DataArrayInt_setPartOfValuesSimple1_2]
+#! [Snippet_DataArrayInt_setPartOfValuesSimple1_3]
+ da.fillWithZero()
+ da.setPartOfValuesSimple1( dv, 0,4,1, 1,2,1 )
+#! [Snippet_DataArrayInt_setPartOfValuesSimple1_3]
+#! [Snippet_DataArrayInt_setPartOfValuesSimple1_4]
+ da.fillWithZero()
+ da.setPartOfValuesSimple1( dv, 1,2,1, 0,4,1 )
+#! [Snippet_DataArrayInt_setPartOfValuesSimple1_4]
+#! [Snippet_DataArrayInt_setPartOfValuesSimple1_5]
+ da.fillWithZero()
+ da.setPartOfValuesSimple1( dv, 0,3,2, 1,4,2 )
+#! [Snippet_DataArrayInt_setPartOfValuesSimple1_5]
+#! [Snippet_DataArrayInt_setPartOfValuesSimple1_6]
+ da2 = da.deepCpy()
+ da2.fillWithZero()
+ da2[ 0:3:2, 1:4:2 ] = dv
+ self.assertTrue( da.isEqual( da2 ))
+#! [Snippet_DataArrayInt_setPartOfValuesSimple1_6]
+ pass
+
+ def testExample_DataArrayDouble_setPartOfValuesSimple2(self):
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple2_1]
+ da=DataArrayDouble.New()
+ da.alloc( 4, 4 )
+ dv = 7
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple2_1]
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple2_2]
+ da.fillWithZero()
+ da[[1,2], [1,2]] = dv
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple2_2]
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple2_3]
+ da.fillWithZero()
+ da[[0,1,2,3], [1]] = dv
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple2_3]
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple2_4]
+ da.fillWithZero()
+ da[[1], [0,1,2,3]] = dv
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple2_4]
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple2_5]
+ da.fillWithZero()
+ da[[0,2], [1,3]] = dv
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple2_5]
+ pass
+
+ def testExample_DataArrayInt_setPartOfValuesSimple2(self):
+#! [Snippet_DataArrayInt_setPartOfValuesSimple2_1]
+ da=DataArrayInt.New()
+ da.alloc( 4, 4 )
+ dv = 7
+#! [Snippet_DataArrayInt_setPartOfValuesSimple2_1]
+#! [Snippet_DataArrayInt_setPartOfValuesSimple2_2]
+ da.fillWithZero()
+ da[[1,2], [1,2]] = dv
+#! [Snippet_DataArrayInt_setPartOfValuesSimple2_2]
+#! [Snippet_DataArrayInt_setPartOfValuesSimple2_3]
+ da.fillWithZero()
+ da[[0,1,2,3], [1]] = dv
+#! [Snippet_DataArrayInt_setPartOfValuesSimple2_3]
+#! [Snippet_DataArrayInt_setPartOfValuesSimple2_4]
+ da.fillWithZero()
+ da[[1], [0,1,2,3]] = dv
+#! [Snippet_DataArrayInt_setPartOfValuesSimple2_4]
+#! [Snippet_DataArrayInt_setPartOfValuesSimple2_5]
+ da.fillWithZero()
+ da[[0,2], [1,3]] = dv
+#! [Snippet_DataArrayInt_setPartOfValuesSimple2_5]
+ pass
+
+ def testExample_DataArrayDouble_setPartOfValuesSimple3(self):
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple3_1]
+ da=DataArrayDouble.New()
+ da.alloc( 4, 4 )
+ dv = 7
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple3_1]
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple3_2]
+ da.fillWithZero()
+ da[[1,2], 1:3] = dv
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple3_2]
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple3_3]
+ da.fillWithZero()
+ da[[0,1,2,3], 1:2] = dv
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple3_3]
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple3_4]
+ da.fillWithZero()
+ da[[1], 0:4] = dv
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple3_4]
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple3_5]
+ da.fillWithZero()
+ da[[0,2], 1:4:2] = dv
+#! [Snippet_DataArrayDouble_setPartOfValuesSimple3_5]
+ pass
+
+ def testExample_DataArrayInt_setPartOfValuesSimple3(self):
+#! [Snippet_DataArrayInt_setPartOfValuesSimple3_1]
+ da=DataArrayInt.New()
+ da.alloc( 4, 4 )
+ dv = 7
+#! [Snippet_DataArrayInt_setPartOfValuesSimple3_1]
+#! [Snippet_DataArrayInt_setPartOfValuesSimple3_2]
+ da.fillWithZero()
+ da[[1,2], 1:3] = dv
+#! [Snippet_DataArrayInt_setPartOfValuesSimple3_2]
+#! [Snippet_DataArrayInt_setPartOfValuesSimple3_3]
+ da.fillWithZero()
+ da[[0,1,2,3], 1:2] = dv
+#! [Snippet_DataArrayInt_setPartOfValuesSimple3_3]
+#! [Snippet_DataArrayInt_setPartOfValuesSimple3_4]
+ da.fillWithZero()
+ da[[1], 0:4] = dv
+#! [Snippet_DataArrayInt_setPartOfValuesSimple3_4]
+#! [Snippet_DataArrayInt_setPartOfValuesSimple3_5]
+ da.fillWithZero()
+ da[[0,2], 1:4:2] = dv
+#! [Snippet_DataArrayInt_setPartOfValuesSimple3_5]
+ pass
+
+ def testExample_DataArrayDouble_setSelectedComponents(self):
+#! [Snippet_DataArrayDouble_setSelectedComponents1]
+ da=DataArrayDouble.New();
+ array1=[1.,2., 3.,4., 5.,6.]
+ da.setValues(array1,3,2)
+ da.setInfoOnComponents( ["a1","a2"])
+#! [Snippet_DataArrayDouble_setSelectedComponents1]
+#! [Snippet_DataArrayDouble_setSelectedComponents2]
+ dv=DataArrayDouble.New();
+ dv.alloc( 4, 4 )
+ dv.fillWithZero()
+ dv.setInfoOnComponents( ["v1","v2","v3","v4"])
+ dv2 = dv.deepCpy()
+ dv.setSelectedComponents( da, [1,0] )
+#! [Snippet_DataArrayDouble_setSelectedComponents2]
+#! [Snippet_DataArrayDouble_setSelectedComponents3]
+ dv2[:3,[1,0]] = da
+ self.assertTrue( dv.isEqualWithoutConsideringStr( dv2, 1e-20 ))
+#! [Snippet_DataArrayDouble_setSelectedComponents3]
+ pass
+
+ def testExample_DataArrayInt_setSelectedComponents(self):
+#! [Snippet_DataArrayInt_setSelectedComponents1]
+ da=DataArrayInt.New();
+ array1=[1,2, 3,4, 5,6]
+ da.setValues(array1,3,2)
+ da.setInfoOnComponents( ["a1","a2"])
+#! [Snippet_DataArrayInt_setSelectedComponents1]
+#! [Snippet_DataArrayInt_setSelectedComponents2]
+ dv=DataArrayInt.New();
+ dv.alloc( 4, 4 )
+ dv.fillWithZero()
+ dv.setInfoOnComponents( ["v1","v2","v3","v4"])
+ dv2 = dv.deepCpy()
+ dv.setSelectedComponents( da, [1,0] )
+#! [Snippet_DataArrayInt_setSelectedComponents2]
+#! [Snippet_DataArrayInt_setSelectedComponents3]
+ dv2[:3,[1,0]] = da
+ self.assertTrue( dv.isEqualWithoutConsideringStr( dv2 ))
+#! [Snippet_DataArrayInt_setSelectedComponents3]
+ pass
+
+ def testExample_DataArrayDouble_getDifferentValues(self):
+#! [Snippet_DataArrayDouble_getDifferentValues1]
+ da=DataArrayDouble.New();
+ array1=[2.3,1.2,1.3,2.3,2.301,0.8]
+ da.setValues(array1,6,1)
+ #
+ dv=da.getDifferentValues(2e-1);
+ expected2=[2.301,1.3,0.8]
+ self.assertEqual(3,dv.getNbOfElems());
+ for i in xrange(3):
+ self.assertAlmostEqual(expected2[i],dv.getIJ(i,0),14);
+ pass
+#! [Snippet_DataArrayDouble_getDifferentValues1]
+ pass
+
+ def testExample_DataArrayDouble_findCommonTuples1(self):
+#! [PySnippet_DataArrayDouble_findCommonTuples1]
+ da=DataArrayDouble.New();
+ array2=[2.3,2.3, 1.2,1.2, 1.3,1.3, 2.3,2.3, 2.301,2.301, 0.8,0.8]
+ da.setValues(array2,6,2)
+#! [PySnippet_DataArrayDouble_findCommonTuples1]
+#! [PySnippet_DataArrayDouble_findCommonTuples2]
+ c,cI=da.findCommonTuples(1e-1);
+ expected3=[0,3,4,1,2]
+ expected4=[0,3,5]
+ self.assertEqual(expected3,c.getValues())
+ self.assertEqual(expected4,cI.getValues())
+#! [PySnippet_DataArrayDouble_findCommonTuples2]
+ pass
+
+ def testExampleDataArrayDoubleMeldWith(self):
+#! [PySnippet_DataArrayDouble_Meld1_1]
+ da1=DataArrayDouble.New();
+ da1.alloc(7,2);
+ da2=DataArrayDouble.New();
+ da2.alloc(7,1);
+ #
+ da1.fillWithValue(7.);
+ da2.iota(0.);
+ da3=da2.applyFunc(3,"10*x*IVec+100*x*JVec+1000*x*KVec");
+ #
+ da1.setInfoOnComponent(0,"c0da1");
+ da1.setInfoOnComponent(1,"c1da1");
+ da3.setInfoOnComponent(0,"c0da3");
+ da3.setInfoOnComponent(1,"c1da3");
+ da3.setInfoOnComponent(2,"c2da3");
+ #
+ da1C=da1.deepCpy();
+ da1.meldWith(da3);
+#! [PySnippet_DataArrayDouble_Meld1_1]
+
+ def testExampleDataArrayIntMeldWith(self):
+#! [PySnippet_DataArrayInt_Meld1_1]
+ da1=DataArrayInt.New();
+ da1.alloc(7,2);
+ da2=DataArrayInt.New();
+ da2.alloc(7,1);
+ #
+ da1.fillWithValue(7);
+ da2.iota(0);
+ #
+ da1.setInfoOnComponent(0,"c0da1");
+ da1.setInfoOnComponent(1,"c1da1");
+ da2.setInfoOnComponent(0,"c0da2");
+ #
+ da1.meldWith(da2);
+#! [PySnippet_DataArrayInt_Meld1_1]
+
+ def testExampleDataArrayDoubleKeepSelectedComponents1(self):
+#! [SnippeDataArrayDoubleKeepSelectedComponents1_1]
+ arr1=[1.,2.,3.,4., # tuple 0
+ 11.,12.,13.,14., # tuple 1
+ 21.,22.,23.,24., # ...
+ 31.,32.,33.,34.,
+ 41.,42.,43.,44.]
+ a1=DataArrayDouble.New()
+ a1.setValues(arr1,5,4)
+ a1.setInfoOnComponent(0,"a");
+ a1.setInfoOnComponent(1,"b");
+ a1.setInfoOnComponent(2,"c");
+ a1.setInfoOnComponent(3,"d");
+#! [SnippeDataArrayDoubleKeepSelectedComponents1_1]
+#! [SnippeDataArrayDoubleKeepSelectedComponents1_2]
+ arr2V=[1,2,1,2,0,0]
+ a2=a1.keepSelectedComponents(arr2V)
+#! [SnippeDataArrayDoubleKeepSelectedComponents1_2]
+ pass
+
+ def testExampleDataArrayIntKeepSelectedComponents1(self):
+#! [SnippeDataArrayIntKeepSelectedComponents1_1]
+ arr1=[1,2,3,4, # tuple 0
+ 11,12,13,14, # tuple 1
+ 21,22,23,24, #
+ 31,32,33,34,
+ 41,42,43,44]
+ a1=DataArrayInt.New()
+ a1.setValues(arr1,5,4)
+ a1.setInfoOnComponent(0,"a");
+ a1.setInfoOnComponent(1,"b");
+ a1.setInfoOnComponent(2,"c");
+ a1.setInfoOnComponent(3,"d");
+#! [SnippeDataArrayIntKeepSelectedComponents1_1]
+#! [SnippeDataArrayIntKeepSelectedComponents1_2]
+ arr2V=[1,2,1,2,0,0]
+ a2=a1.keepSelectedComponents(arr2V)
+#! [SnippeDataArrayIntKeepSelectedComponents1_2]
+#! [SnippeDataArrayIntKeepSelectedComponents1_3]
+ a3=a1[:,arr2V ]
+#! [SnippeDataArrayIntKeepSelectedComponents1_3]
+ pass
+
def testExampleFieldDoubleBuildSubPart1(self):
from MEDCouplingDataForTest import MEDCouplingDataForTest
#! [PySnippetFieldDoubleBuildSubPart1_1]
namespace ParaMEDMEM
{
+ typedef enum
+ {
+ IK_ONLY_PREFERED = 0,
+ NOT_IK_ONLY_PREFERED = 1,
+ IK_ONLY_FORCED = 2,
+ NOT_IK_ONLY_FORCED =3
+ } InterpolationMatrixPolicy;
+
class MEDCouplingRemapper : public TimeLabel, public INTERP_KERNEL::InterpolationOptions
{
private:
void reverseTransfer(MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *transferField(const MEDCouplingFieldDouble *srcField, double dftValue) throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *reverseTransferField(const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
- bool setOptionInt(const std::string& key, int value);
- bool setOptionDouble(const std::string& key, double value);
- bool setOptionString(const std::string& key, const std::string& value);
+ bool setOptionInt(const std::string& key, int value) throw(INTERP_KERNEL::Exception);
+ bool setOptionDouble(const std::string& key, double value) throw(INTERP_KERNEL::Exception);
+ bool setOptionString(const std::string& key, const std::string& value) throw(INTERP_KERNEL::Exception);
+ int getInterpolationMatrixPolicy() const throw(INTERP_KERNEL::Exception);
+ void setInterpolationMatrixPolicy(int newInterpMatPol) throw(INTERP_KERNEL::Exception);
//
int nullifiedTinyCoeffInCrudeMatrixAbs(double maxValAbs) throw(INTERP_KERNEL::Exception);
int nullifiedTinyCoeffInCrudeMatrix(double scaleFactor) throw(INTERP_KERNEL::Exception);
double getMaxValueInCrudeMatrix() const throw(INTERP_KERNEL::Exception);
%extend
{
- PyObject *getCrudeMatrix() const
+ PyObject *getCrudeMatrix() const throw(INTERP_KERNEL::Exception)
{
const std::vector<std::map<int,double> >& m=self->getCrudeMatrix();
std::size_t sz=m.size();
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
else
- return 0;
+ { nbTuples=0; return 0; }
}
}
status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
{
e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
sw=3;
- if(e->getNumberOfCompo()==nbCompExpected)
+ if(e)
+ {
+ if(e->getNumberOfCompo()==nbCompExpected)
+ {
+ nbTuples=1;
+ return e->getConstPointer();
+ }
+ else
+ {
+ std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ else
+ {
+ if(throwIfNullPt)
+ {
+ std::ostringstream oss; oss << msg << " null pointer not accepted!";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ else
+ { nbTuples=0; return 0; }
+ }
+ }
+ throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
+}
+
+/*!
+ * if value int -> cpp val sw=1
+ * if value double -> cpp val sw=1
+ * if value DataArrayDouble -> cpp DataArrayDouble sw=2
+ * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
+ * if value list[int,double] -> cpp std::vector<double> sw=4
+ * if value tuple[int,double] -> cpp std::vector<double> sw=4
+ */
+static const double *convertObjToPossibleCpp5_SingleCompo(PyObject *value, int& sw, double& val, std::vector<double>& f,
+ const char *msg, bool throwIfNullPt, int& nbTuples) throw(INTERP_KERNEL::Exception)
+{
+ ParaMEDMEM::DataArrayDouble *d=0;
+ ParaMEDMEM::DataArrayDoubleTuple *e=0;
+ sw=-1;
+ if(PyFloat_Check(value))
+ {
+ val=PyFloat_AS_DOUBLE(value);
+ sw=1;
+ nbTuples=1;
+ return &val;
+ }
+ if(PyInt_Check(value))
+ {
+ val=(double)PyInt_AS_LONG(value);
+ sw=1;
+ nbTuples=1;
+ return &val;
+ }
+ if(PyTuple_Check(value))
+ {
+ int size=PyTuple_Size(value);
+ f.resize(size);
+ for(int i=0;i<size;i++)
{
- nbTuples=1;
+ PyObject *o=PyTuple_GetItem(value,i);
+ if(PyFloat_Check(o))
+ f[i]=PyFloat_AS_DOUBLE(o);
+ else if(PyInt_Check(o))
+ f[i]=(double)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=4;
+ nbTuples=size;
+ return &f[0];
+ }
+ if(PyList_Check(value))
+ {
+ int size=PyList_Size(value);
+ f.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyList_GetItem(value,i);
+ if(PyFloat_Check(o))
+ f[i]=PyFloat_AS_DOUBLE(o);
+ else if(PyInt_Check(o))
+ f[i]=(double)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=4;
+ nbTuples=size;
+ return &f[0];
+ }
+ void *argp;
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
+ if(SWIG_IsOK(status))
+ {
+ d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
+ sw=2;
+ if(d)
+ {
+ if(d->getNumberOfComponents()==1)
+ {
+ nbTuples=d->getNumberOfTuples();
+ return d->getConstPointer();
+ }
+ else
+ {
+ std::ostringstream oss; oss << msg << "nb of components expected to be one, and input has " << d->getNumberOfComponents() << " components !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ else
+ {
+ if(throwIfNullPt)
+ {
+ std::ostringstream oss; oss << msg << " null pointer not accepted!";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ else
+ { nbTuples=0; return 0; }
+ }
+ }
+ status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
+ if(SWIG_IsOK(status))
+ {
+ e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
+ sw=3;
+ if(e)
+ {
+ nbTuples=e->getNumberOfCompo();
return e->getConstPointer();
}
else
{
- std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ if(throwIfNullPt)
+ {
+ std::ostringstream oss; oss << msg << " null pointer not accepted!";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ else
+ { nbTuples=0; return 0; }
}
}
throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
}
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
- std::set<int> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
//
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
arrPart->renumberInPlace(renumTupleIds->begin());
arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
bool ret=false;
- std::set<int>::const_iterator idIt=diffVals.begin();
+ const int *idIt=diffVals->begin();
std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
int offset2=0;
- for(std::size_t i=0;i<diffVals.size();i++,idIt++)
+ for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
const DataArrayInt *da=disc2->getArrayOfDiscIds();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
- std::set<int> retTmp=da2->getDifferentValues();
- if(retTmp.find(-1)!=retTmp.end())
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
+ if(retTmp->presenceOfValue(-1))
throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
- std::vector<int> ret(retTmp.begin(),retTmp.end());
+ std::vector<int> ret(retTmp->begin(),retTmp->end());
return ret;
}
throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
const DataArrayInt *da=disc2->getArrayOfDiscIds();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
- std::set<int> retTmp=da2->getDifferentValues();
- if(retTmp.find(-1)!=retTmp.end())
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
+ if(retTmp->presenceOfValue(-1))
throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
- std::vector<int> ret(retTmp.begin(),retTmp.end());
+ std::vector<int> ret(retTmp->begin(),retTmp->end());
return ret;
}
#include <vector>
#include <string>
#include <list>
+#include <set>
#include "med.h"
const DataArrayInt *fieldFamIds=getFamilyFieldAtLevel(meshDimRelToMaxExt);
if(fieldFamIds==0)
throw INTERP_KERNEL::Exception("MEDFileMesh::createGroupOnAll : Family field arr ids is not defined for this level !");
- std::set<int> famIds=fieldFamIds->getDifferentValues();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> famIds=fieldFamIds->getDifferentValues();
std::vector<std::string> familiesOnWholeGroup;
- for(std::set<int>::const_iterator it=famIds.begin();it!=famIds.end();it++)
+ for(const int *it=famIds->begin();it!=famIds->end();it++)
{
bool tmp;
familiesOnWholeGroup.push_back(findOrCreateAndGiveFamilyWithId(*it,tmp));
const DataArrayInt *fieldFamIds=getFamilyFieldAtLevel(*it);
if(fieldFamIds)
{
- std::set<int> famIds3=fieldFamIds->getDifferentValues();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> famIds3=fieldFamIds->getDifferentValues();
std::vector<int> tmp;
- std::set_intersection(famIds3.begin(),famIds3.end(),famIds2.begin(),famIds2.end(),std::back_insert_iterator< std::vector<int> >(tmp));
+ std::set_intersection(famIds3->begin(),famIds3->end(),famIds2.begin(),famIds2.end(),std::back_insert_iterator< std::vector<int> >(tmp));
for(std::vector<int>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
{
ret=false;
const DataArrayInt *fam=getFamilyFieldAtLevel(*it);
if(fam)
{
- std::set<int> tmp=fam->getDifferentValues();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=fam->getDifferentValues();
std::set<int> r2;
- std::set_intersection(tmp.begin(),tmp.end(),allFamIds.begin(),allFamIds.end(),std::inserter(r2,r2.end()));
+ std::set_intersection(tmp->begin(),tmp->end(),allFamIds.begin(),allFamIds.end(),std::inserter(r2,r2.end()));
if(!r2.empty())
famIdsToRenum[*it].insert(famIdsToRenum[*it].end(),r2.begin(),r2.end());
std::set<int> r3;
- std::set_union(tmp.begin(),tmp.end(),allFamIds.begin(),allFamIds.end(),std::inserter(r3,r3.end()));
+ std::set_union(tmp->begin(),tmp->end(),allFamIds.begin(),allFamIds.end(),std::inserter(r3,r3.end()));
}
}
if(famIdsToRenum.empty())
if(fam)
{
int refId=1;
- std::set<int> tmp=fam->getDifferentValues();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=fam->getDifferentValues();
std::map<int,int> ren;
- for(std::set<int>::const_iterator it=tmp.begin();it!=tmp.end();it++,refId++)
+ for(const int *it=tmp->begin();it!=tmp->end();it++,refId++)
ren[*it]=refId;
int nbOfTuples=fam->getNumberOfTuples();
int *start=const_cast<DataArrayInt *>(fam)->getPointer();
for(int *w=start;w!=start+nbOfTuples;w++)
*w=ren[*w];
- for(std::set<int>::const_iterator it=tmp.begin();it!=tmp.end();it++)
+ for(const int *it=tmp->begin();it!=tmp->end();it++)
{
if(allIds->presenceOfValue(*it))
{
if(fam)
{
int refId=-1;
- std::set<int> tmp=fam->getDifferentValues();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=fam->getDifferentValues();
std::map<int,int> ren;
- for(std::set<int>::const_iterator it=tmp.begin();it!=tmp.end();it++,refId--)
+ for(const int *it=tmp->begin();it!=tmp->end();it++,refId--)
ren[*it]=refId;
int nbOfTuples=fam->getNumberOfTuples();
int *start=const_cast<DataArrayInt *>(fam)->getPointer();
for(int *w=start;w!=start+nbOfTuples;w++)
*w=ren[*w];
- for(std::set<int>::const_iterator it=tmp.begin();it!=tmp.end();it++)
+ for(const int *it=tmp->begin();it!=tmp->end();it++)
{
if(allIds->presenceOfValue(*it))
{
DataArrayInt *fam=const_cast<DataArrayInt*>(getFamilyFieldAtLevel(*it2));
if(fam)
{
- std::set<int> tmp=fam->getDifferentValues();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=fam->getDifferentValues();
fam->fillWithZero();
- for(std::set<int>::const_iterator it3=tmp.begin();it3!=tmp.end();it3++)
+ for(const int *it3=tmp->begin();it3!=tmp->end();it3++)
if(allIds->presenceOfValue(*it3))
{
std::string famName=getFamilyNameGivenId(*it3);
const DataArrayInt *fam=getFamilyFieldAtLevel(1);
if(fam)
{
- std::set<int> tmp=fam->getDifferentValues();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=fam->getDifferentValues();
std::map<int,int> ren;
- for(std::set<int>::const_iterator it=tmp.begin();it!=tmp.end();it++,refId++)
+ for(const int *it=tmp->begin();it!=tmp->end();it++,refId++)
ren[*it]=refId;
int nbOfTuples=fam->getNumberOfTuples();
int *start=const_cast<DataArrayInt *>(fam)->getPointer();
for(int *w=start;w!=start+nbOfTuples;w++)
*w=ren[*w];
- for(std::set<int>::const_iterator it=tmp.begin();it!=tmp.end();it++)
+ for(const int *it=tmp->begin();it!=tmp->end();it++)
{
if(allIds->presenceOfValue(*it))
{
const DataArrayInt *fam=getFamilyFieldAtLevel(1);
if(fam)
{
- std::set<int> tmp=fam->getDifferentValues();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=fam->getDifferentValues();
std::map<int,int> ren;
- for(std::set<int>::const_iterator it=tmp.begin();it!=tmp.end();it++,refId--)
+ for(const int *it=tmp->begin();it!=tmp->end();it++,refId--)
ren[*it]=refId;
int nbOfTuples=fam->getNumberOfTuples();
int *start=const_cast<DataArrayInt *>(fam)->getPointer();
for(int *w=start;w!=start+nbOfTuples;w++)
*w=ren[*w];
- for(std::set<int>::const_iterator it=tmp.begin();it!=tmp.end();it++)
+ for(const int *it=tmp->begin();it!=tmp->end();it++)
{
if(allIds->presenceOfValue(*it))
{
if(!_families.empty())
offset=getMaxFamilyId()+1;
TranslateFamilyIds(offset,fam,fidsOfGroups);
- std::set<int> ids=fam->getDifferentValues();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=fam->getDifferentValues();
appendFamilyEntries(ids,fidsOfGroups,grpsName2);
setFamilyFieldArr(meshDimRelToMaxExt,fam);
}
* not in '_families'. Groups information are given in parameters in order to give to families representative names.
* For the moment, the two last input parameters are not taken into account.
*/
-void MEDFileMesh::appendFamilyEntries(const std::set<int>& famIds, const std::vector< std::vector<int> >& fidsOfGrps, const std::vector<std::string>& grpNames)
+void MEDFileMesh::appendFamilyEntries(const DataArrayInt *famIds, const std::vector< std::vector<int> >& fidsOfGrps, const std::vector<std::string>& grpNames)
{
std::map<int,std::string> famInv;
- for(std::set<int>::const_iterator it=famIds.begin();it!=famIds.end();it++)
+ for(const int *it=famIds->begin();it!=famIds->end();it++)
{
std::ostringstream oss;
oss << "Family_" << (*it);
for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
{
const DataArrayInt *ffield=getFamilyFieldAtLevel(*it);
- std::set<int> ids=ffield->getDifferentValues();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=ffield->getDifferentValues();
std::set<int> res;
- std::set_union(ids.begin(),ids.end(),allFamsIds.begin(),allFamsIds.end(),std::inserter(res,res.begin()));
+ std::set_union(ids->begin(),ids->end(),allFamsIds.begin(),allFamsIds.end(),std::inserter(res,res.begin()));
allFamsIds=res;
}
std::set<std::string> famNamesToKill;
std::list< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > allFamIds=getAllNonNullFamilyIds();
allFamIds.erase(std::find(allFamIds.begin(),allFamIds.end(),famArrTmp));
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> famIds=famArr->selectByTupleIdSafe(ids->begin(),ids->end());
- std::set<int> diffFamIds=famIds->getDifferentValues();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffFamIds=famIds->getDifferentValues();
std::vector<int> familyIds;
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerfamiliyIds;
int maxVal=getTheMaxFamilyId()+1;
std::map<std::string, std::vector<std::string> > groups(_groups);
std::vector<std::string> fams;
bool created(false);
- for(std::set<int>::const_iterator famId=diffFamIds.begin();famId!=diffFamIds.end();famId++)
+ for(const int *famId=diffFamIds->begin();famId!=diffFamIds->end();famId++)
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids2Tmp=famIds->getIdsEqual(*famId);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids2=ids->selectByTupleId(ids2Tmp->begin(),ids2Tmp->end());
void dealWithTinyInfo(const MEDCouplingMesh *m) throw(INTERP_KERNEL::Exception);
virtual void synchronizeTinyInfoOnLeaves() const = 0;
void getFamilyRepr(std::ostream& oss) const;
- virtual void appendFamilyEntries(const std::set<int>& famIds, const std::vector< std::vector<int> >& fidsOfGrps, const std::vector<std::string>& grpNames);
+ virtual void appendFamilyEntries(const DataArrayInt *famIds, const std::vector< std::vector<int> >& fidsOfGrps, const std::vector<std::string>& grpNames);
virtual void changeFamilyIdArr(int oldId, int newId) throw(INTERP_KERNEL::Exception) = 0;
static void TranslateFamilyIds(int offset, DataArrayInt *famArr, std::vector< std::vector<int> >& famIdsPerGrp);
static void ChangeAllGroupsContainingFamily(std::map<std::string, std::vector<std::string> >& groups, const char *familyNameToChange, const std::vector<std::string>& newFamiliesNames) throw(INTERP_KERNEL::Exception);
#include "InterpKernelAutoPtr.hxx"
+#include <set>
+
using namespace ParaMEDMEM;
MEDFileParameter1TS::MEDFileParameter1TS(int iteration, int order, double time):_iteration(iteration),_order(order),_time(time)
#! [PySnippetMeshAdvAPI1_2]
self.assertTrue(isinstance(myMesh,MEDCouplingUMesh))
myMesh.setName(meshName)
- MEDLoader.WriteUMesh("wFile1.med",myMesh,True)
+ MEDLoader.WriteUMesh("wFile1.med",myMesh,False)
#! [PySnippetMeshAdvAPI1_2]
f=myMesh.getMeasureField(ON_CELLS)
f=f.buildNewTimeReprFromThis(ONE_TIME,False)
self.assertTrue(fs[2]=="Field3");
self.assertTrue(fs[3]=="Field8");
pass
+
+ def testBigNbOfCompoNonReg(self):
+ fileName="Pyfile57.med"
+ m=MEDLoader.MEDCouplingCMesh() ; m.setCoords(MEDLoader.DataArrayDouble([0,1,2,3]),MEDLoader.DataArrayDouble([0,1]),MEDLoader.DataArrayDouble([0,1]))
+ m=m.buildUnstructured() ; m.setName("TinyMesh")
+ f=MEDLoader.MEDCouplingFieldDouble(MEDLoader.ON_CELLS) ; f.setMesh(m)
+ nbOfCompo=4100
+ arr=MEDLoader.DataArrayDouble(nbOfCompo*3) ; arr.iota()
+ arr.rearrange(nbOfCompo)
+ arr.setInfoOnComponents(["c%i"%(i) for i in xrange(nbOfCompo)])
+ f.setArray(arr)
+ f.setName("FieldBigCompo")
+ MEDLoader.MEDLoader.WriteField(fileName,f,True)
+ f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,m.getName(),0,f.getName(),-1,-1)
+ self.assertTrue(f.isEqual(f2,1e-12,1e-12))
+ pass
pass
unittest.main()