Files
ResInsight/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.h
T
Magne Sjaastad 56e98ba1c4 #14476 ApplicationLibCode: Replace CVF_ASSERT with CAF_ASSERT
Migrate all assert macros in ApplicationLibCode to CAF_ASSERT and remove every
use of cvfAssert.h.

CVF_ASSERT is replaced one to one. CVF_TIGHT_ASSERT is also replaced by
CAF_ASSERT, which is semantically exact: CVF_ENABLE_TIGHT_ASSERTS is 1 only
under _DEBUG, and that is what CAF_ASSERT now does. The two CVF_FAIL_MSG sites
become CAF_ASSERT( false && "message" ), preserving the message with the idiom
already used elsewhere in the code base.

Counts before and after: CVF_ASSERT 1044 to 0, CVF_TIGHT_ASSERT 66 to 0,
CVF_FAIL_MSG 2 to 0, cvfAssert.h references 154 to 0.

Include handling: files that included cvfAssert.h directly now include
cafAssert.h instead, includes left dead by the migration are removed, and files
that were relying on cvfAssert.h transitively get an explicit cafAssert.h. Files
that reach cafAssert.h through another caf header are left unchanged; a missing
include here is a compile error, not a silently disabled assert.

ResultStatisticsCache links only LibCore and therefore had no path to
cafAssert.h. Add the cafPdmCore directory as a private include path rather than
linking the library, since cafAssert.h is header only.

Note that this stops these asserts from firing in Release and RelWithDebInfo,
where CVF_ASSERT was previously active.
2026-08-07 15:05:57 +02:00

146 lines
5.0 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight 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 General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <cstdlib>
#include "RigFemResultPosEnum.h"
#include "RigFemTypes.h"
#include "cvfBoundingBox.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include <array>
#include <string>
#include <vector>
class RigFemPartGrid;
namespace cvf
{
class BoundingBoxTree;
}
class RigFemPartNodes
{
public:
std::vector<int> nodeIds;
std::vector<cvf::Vec3f> coordinates;
};
class RigFemPart : public cvf::Object
{
public:
RigFemPart();
~RigFemPart() override;
int elementPartId() const;
void setElementPartId( int partId );
void preAllocateElementStorage( int elementCount );
void appendElement( RigElementType elmType, int elementId, const int* connectivities );
int elementCount() const;
int nodeCount() const;
int allConnectivitiesCount() const;
int elmId( size_t elementIdx ) const;
RigElementType elementType( size_t elementIdx ) const;
bool isHexahedron( size_t elementIdx ) const;
const int* connectivities( size_t elementIdx ) const;
bool fillElementCoordinates( size_t elementIdx, std::array<cvf::Vec3d, 8>& coordinates ) const;
size_t elementNodeResultIdx( int elementIdx, int elmLocalNodeIdx ) const;
size_t elementNodeResultCount() const;
int nodeIdxFromElementNodeResultIdx( size_t elmNodeResultIdx ) const;
size_t resultValueIdxFromResultPosType( RigFemResultPosEnum resultPosType, int elementIdx, int elmLocalNodeIdx ) const;
RigFemPartNodes& nodes();
const RigFemPartNodes& nodes() const;
void assertNodeToElmIndicesIsCalculated();
const std::vector<int>& elementsUsingNode( int nodeIndex ) const;
const std::vector<unsigned char>& elementLocalIndicesForNode( int nodeIndex ) const;
void assertElmNeighborsIsCalculated();
int elementNeighbor( int elementIndex, int faceIndex ) const;
int neighborFace( int elementIndex, int faceIndex ) const;
cvf::BoundingBox boundingBox() const;
float characteristicElementSize() const;
const std::vector<int>& possibleGridCornerElements() const;
std::vector<size_t> findIntersectingElementIndices( const cvf::BoundingBox& inputBB ) const;
std::vector<size_t> findIntersectingElementsWithExistingSearchTree( const cvf::BoundingBox& inputBB ) const;
void ensureIntersectionSearchTreeIsBuilt() const;
cvf::Vec3f faceNormal( int elementIndex, int faceIndex ) const;
const RigFemPartGrid* getOrCreateStructGrid() const;
void setInvertIJKInStructGrid( bool invert );
const std::vector<int>& elementIdxToId() const;
void setName( std::string name );
std::string name() const;
void setEnabled( bool enable );
bool enabled() const;
void addElementSet( std::string name, const std::vector<size_t>& elementIds );
std::vector<std::string> elementSetNames() const;
std::vector<size_t> elementSet( int setIndex ) const;
private:
int m_elementPartId;
std::string m_name;
bool m_enabled;
bool m_invertIJKInStructGrid;
std::vector<int> m_elementId;
std::vector<RigElementType> m_elementTypes;
std::vector<size_t> m_elementConnectivityStartIndices;
std::vector<int> m_allElementConnectivities;
std::vector<std::string> m_elementSetNames;
std::vector<std::vector<size_t>> m_elementIndexSets;
RigFemPartNodes m_nodes;
mutable cvf::ref<RigFemPartGrid> m_structGrid;
void calculateNodeToElmRefs();
std::vector<std::vector<int>> m_nodeToElmRefs; // Needs a more memory friendly structure
std::vector<std::vector<unsigned char>> m_nodeGlobalToLocalIndices;
void calculateElmNeighbors();
struct Neighbors
{
int indicesToNeighborElms[6];
char faceInNeighborElm[6];
};
std::vector<Neighbors> m_elmNeighbors;
std::vector<int> m_possibleGridCornerElements;
mutable float m_characteristicElementSize;
mutable cvf::BoundingBox m_boundingBox;
mutable cvf::ref<cvf::BoundingBoxTree> m_elementSearchTree;
};