Commit 64dbf266 authored by Tomáš Jakubec's avatar Tomáš Jakubec
Browse files

I realized, that it would be better to implement methods working with mesh...

I realized, that it would be better to implement methods working with mesh elements in the class UnstructuredMesh.
Finally, I managed to implement concept of unstructured mesh in any dimension.
Further work will be done after consultations.
parent 7e9a572b
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
TEMPLATE = app
CONFIG += console c++11
CONFIG += console c++14
CONFIG -= app_bundle
CONFIG -= qt

@@ -12,7 +12,11 @@ HEADERS += \
    cellconnection.h \
    ../debug/debug.h \
    ../debug/htmllogger.h \
    computationaly_significant_element.h \
    inline_array_operations.h \
    mesh_element.h \
    mesh_functions.h \
    unstructed_mesh_define.h \
    unstructuredmesh.h \
    vector.h \
    vertex.h
+13 −4
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.8.2, 2019-06-07T12:04:09. -->
<!-- Written by QtCreator 4.9.1, 2019-06-14T12:01:23. -->
<qtcreator>
 <data>
  <variable>EnvironmentId</variable>
@@ -254,6 +254,15 @@
   <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
   <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
   <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
    <value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
    <valuelist type="QVariantList" key="Analyzer.Perf.Events">
     <value type="QString">cpu-cycles</value>
    </valuelist>
    <valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
    <value type="int" key="Analyzer.Perf.Frequency">250</value>
    <value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
    <value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
    <value type="int" key="Analyzer.Perf.StackSize">4096</value>
    <value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
    <value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
    <value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
@@ -268,6 +277,7 @@
    <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
    <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
    <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
    <value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
    <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
    <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
    <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
@@ -298,7 +308,6 @@
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Unstructured_mesh</value>
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:D:/Skola/Vyzkumak/nova sit/Unstructured_mesh/Unstructured_mesh.pro</value>
    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">Unstructured_mesh.pro</value>
    <value type="QString" key="RunConfiguration.Arguments"></value>
    <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
    <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
@@ -319,10 +328,10 @@
 </data>
 <data>
  <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
  <value type="int">20</value>
  <value type="int">21</value>
 </data>
 <data>
  <variable>Version</variable>
  <value type="int">20</value>
  <value type="int">21</value>
 </data>
</qtcreator>
+15 −11
Original line number Diff line number Diff line
@@ -28,13 +28,12 @@ public:
    void SetNextBElemWRTCR(indexType nextIndex);

    void SetNextBElemWRTCL(indexType nextIndex);
    bool SetNextEdge(indexType nextEdgeIndex, indexType cellIndex);

    bool SetNextBElem(indexType nextBElemIndex, indexType cellIndex);

    indexType GetNextBElemWRTCL() const;

    indexType GetNextBElemWRTCR() const {
        return NextBElemWRTCR;
    }
    indexType GetNextBElemWRTCR() const;

    indexType GetNextBElem(indexType cellIndex) const;

@@ -66,7 +65,7 @@ void CellBoundaryConnection<indexType>::SetNextBElemWRTCL(indexType nextIndex){
}

template<typename indexType>
bool CellBoundaryConnection<indexType>::SetNextEdge(indexType nextEdgeIndex, indexType cellIndex){
bool CellBoundaryConnection<indexType>::SetNextBElem(indexType nextBElemIndex, indexType cellIndex){

    // CellIndex is invalid then false returned
    if (cellIndex == INVALID_INDEX(indexType)){
@@ -76,14 +75,14 @@ bool CellBoundaryConnection<indexType>::SetNextEdge(indexType nextEdgeIndex, ind
    // then is posible to set up invalid indexes
    if (CellConnection<indexType>::GetCellLeftIndex() == cellIndex) {

        SetNextBElemWRTCL(nextEdgeIndex);
        SetNextBElemWRTCL(nextBElemIndex);
        return true;

    }

    if (CellConnection<indexType>::GetCellRightIndex() == cellIndex){

        SetNextBElemWRTCR(nextEdgeIndex);
        SetNextBElemWRTCR(nextBElemIndex);
        return true;

    }
@@ -93,7 +92,7 @@ bool CellBoundaryConnection<indexType>::SetNextEdge(indexType nextEdgeIndex, ind
    // CellRightIndex is set as cellIndex
    if (CellConnection<indexType>::GetCellLeftIndex() == INVALID_INDEX(indexType)){

        SetCellLeftIndex(cellIndex);
        CellConnection<indexType>::SetCellLeftIndex(cellIndex);

    }

@@ -101,7 +100,7 @@ bool CellBoundaryConnection<indexType>::SetNextEdge(indexType nextEdgeIndex, ind
    // then nextEdgeWRTCL is set as nextEdgeIndex, ret true
    if (cellIndex == CellConnection<indexType>::GetCellLeftIndex()) {

        SetNextBElemWRTCL(nextEdgeIndex);
        SetNextBElemWRTCL(nextBElemIndex);

        return true;

@@ -111,14 +110,14 @@ bool CellBoundaryConnection<indexType>::SetNextEdge(indexType nextEdgeIndex, ind
        // but CellLeftIndex is already filled
        // then set CellLeftIndex as cellIndex
        if(CellConnection<indexType>::GetCellRightIndex() == INVALID_INDEX(indexType)){
            SetCellRightIndex(cellIndex);
            CellConnection<indexType>::SetCellRightIndex(cellIndex);
        }

        // Parameter cellIndex is equal to CellLeftIndex then
        // set NextEdgeWRTCR as nextEdgeIndex, ret true
        if (cellIndex == CellConnection<indexType>::GetCellRightIndex()){

            SetNextBElemWRTCR(nextEdgeIndex);
            SetNextBElemWRTCR(nextBElemIndex);

            return true;

@@ -142,6 +141,11 @@ indexType CellBoundaryConnection<indexType>::GetNextBElemWRTCL() const {
    return NextBElemWRTCL;
}

template<typename indexType>
indexType CellBoundaryConnection<indexType>::GetNextBElemWRTCR() const {
    return NextBElemWRTCR;
}

template<typename indexType>
indexType CellBoundaryConnection<indexType>::GetNextBElem(indexType cellIndex) const{
    // If cell is nullptr then ret nullptr
+39 −0
Original line number Diff line number Diff line
#ifndef COMPUTATIONALY_SIGNIFICANT_ELEMENT_H
#define COMPUTATIONALY_SIGNIFICANT_ELEMENT_H
#include "vertex.h"

template <unsigned int MeshDim, typename Real>
class ComputationalySignificantElement
{
protected:
    Vertex<MeshDim, Real> Center;
    int Flag;
public:
    ComputationalySignificantElement() {
        Center = {};
        Flag = int();
    }

    Vertex<MeshDim, Real>& GetCenter(){
        return Center;
    }

    const Vertex<MeshDim, Real>& GetCenter() const {
        return Center;
    }

    void SetCenter(const Vertex<MeshDim, Real>& v) {
        Center = v;
    }

    int& GetFlag() {
        return Flag;
    }

    const int& GetFlag() const {
        return Flag;
    }
};


#endif // COMPUTATIONALY_SIGNIFICANT_ELEMENT_H
+95 −0
Original line number Diff line number Diff line
#ifndef INLINE_ARRAY_OPERATIONS_H
#define INLINE_ARRAY_OPERATIONS_H


template <unsigned int N, typename Real>
struct inlineScalarProduct {
    static inline Real computation(const Real *x, const Real *y){
        return x[N-1] * y[N-1] + inlineScalarProduct<N-1, Real>::computation(x, y);
    }
};


template <typename Real>
struct inlineScalarProduct<1, Real>
{
    static inline double computation(const Real *x, const Real *y){
        return x[0] * y[0];
    }
};




template <unsigned int N, typename Real>
struct inlineAddition{
    static inline void computation(Real *res, const Real *x, const Real *y){
        res[N-1] = x[N-1] + y[N-1];
        inlineAddition<N-1, Real>::computation(res, x, y);
    }
    static inline void computation(Real *x, const Real *y){
        x[N-1] += y[N-1];
        inlineAddition<N-1, Real>::computation(x, y);
    }
};

template <typename Real>
struct inlineAddition<1, Real>{
    static inline void computation(Real *res, const Real *x, const Real *y){
        res[0] = x[0] + y[0];
    }
    static inline void computation(Real *x, const Real *y){
        x[0] += y[0];
    }
};


template <unsigned int N, typename Real>
struct inlineSubtraction{
    static inline void computation(Real *res, const Real *x, const Real *y){
        res[N-1] = x[N-1] - y[N-1];
        inlineSubtraction<N-1, Real>::computation(res, x, y);
    }
    static inline void computation(Real *x, const Real *y){
        x[N-1] -= y[N-1];
        inlineSubtraction<N-1, Real>::computation(x, y);
    }
};

template <typename Real>
struct inlineSubtraction<1, Real>{
    static inline void computation(Real *res, const Real *x, const Real *y){
        res[0] = x[0] - y[0];
    }
    static inline void computation(Real *x, const Real *y){
        x[0] -= y[0];
    }
};



template <unsigned int N, typename Real>
struct inlineMultiplication{
    static inline void computation(Real *res, const Real *x, const Real& alpha){
        res[N-1] = x[N-1] * alpha;
        inlineMultiplication<N-1, Real>::computation(res, x, alpha);
    }
    static inline void computation(Real *x, const Real alpha){
        x[N-1] *= alpha;
        inlineMultiplication<N-1, Real>::computation(x, alpha);
    }
};

template <typename Real>
struct inlineMultiplication<1, Real>{
    static inline void computation(Real *res, const Real *x, const Real& alpha){
        res[0] = x[0] * alpha;
    }
    static inline void computation(Real *x, const Real alpha){
        x[0] *= alpha;
    }
};



#endif // INLINE_ARRAY_OPERATIONS_H
Loading