Skip to content
Snippets Groups Projects
Commit 4bcea78a authored by Kitware Robot's avatar Kitware Robot Committed by Spiros Tsalikis
Browse files

verdict 2022-03-03 (3f2672f6)

Code extracted from:

    https://gitlab.kitware.com/third-party/verdict.git

at commit 3f2672f6e1193bbbb0be897c4f9fba1fc7ca0426 (for/vtk-20220303-1.4.0).
parents
Branches
Tags
No related merge requests found
* -whitespace
set(headers
verdict.h
VerdictVector.hpp
verdict_defines.hpp)
set(sources
V_EdgeMetric.cpp
V_GaussIntegration.cpp
V_GaussIntegration.hpp
V_HexMetric.cpp
V_KnifeMetric.cpp
V_PyramidMetric.cpp
V_QuadMetric.cpp
V_TetMetric.cpp
V_TriMetric.cpp
V_WedgeMetric.cpp
VerdictVector.cpp)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/verdict_config.h.in
${CMAKE_CURRENT_BINARY_DIR}/verdict_config.h
@ONLY)
vtk_module_add_module(VTK::verdict
HEADERS ${headers}
SOURCES ${sources})
LICENSE 0 → 100644
Copyright 2003,2006,2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# verdict fork for VTK
This branch contains changes required to embed verdict in VTK.
* Ignore whitespace for VTK's commit checks.
* Add VTK-specific CMakeLists.txt to integrate into VTK's build system.
* mangle namespace `verdict` as `vtkverdict`
# Verdict
## Compute quality functions of 2 and 3-dimensional regions.
## Changelog
What's new for 1.4:
- Add inradius metrics for several element types
- Bug fixes
What's new for 1.3:
- Thread safety for all functions and simplified API
- Some existing metrics implemented for pyramid and wedge elements
- New inradius and timestep metrics
- New implementation for some higher order elements
## Building Verdict
To build with CMake
1. Set up a build directory
2. Change to this directory
3. Type `ccmake /path/to/verdict` but replace
`/path/to/verdict` with the path to the directory
containing this read-me file.
4. Fill the required fields and press the 'c' key
NB: This process is iterative;
you may need to change values and reconfigure before continuing.
5. When the 'g' option becomes available, press the 'g' key to generate
the Makefile and exit CMake.
6. Build with `make`
7. Install with `make install`
## Using Verdict
If you do not already have verdict installed on your system,
see below for instructions to compile it.
Once you have verdict installed, you may use it in your
own project by adding
```cmake
find_package(Verdict)
```
to your `CMakeLists.txt` file.
Now you can link your executable to the verdict library.
Assume you have an executable named `example`;
verdict uses CMake's _namespace_ feature, so you should
link to the verdict library like so:
```cmake
target_link_libraries(example
PUBLIC
Verdict::verdict
)
```
Note that executables do not need to specify `PUBLIC`, `PRIVATE`,
or `INTERFACE` linkage, but libraries must so that transitive
dependencies can be resolved by cmake.
`verdict.h` is the only header file you need to include.
/*=========================================================================
Module: V_EdgeMetric.cpp
Copyright 2003,2006,2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
Under the terms of Contract DE-NA0003525 with NTESS,
the U.S. Government retains certain rights in this software.
See LICENSE for details.
=========================================================================*/
/*
*
* V_EdgeMetric.cpp contains quality calculations for edges
*
* This file is part of VERDICT
*
*/
#include "verdict.h"
#include <cmath>
namespace VERDICT_NAMESPACE
{
/*!\brief Length of and edge.
* Length is calculated by taking the distance between the end nodes.
*/
double edge_length(int /*num_nodes*/, const double coordinates[][3])
{
double x = coordinates[1][0] - coordinates[0][0];
double y = coordinates[1][1] - coordinates[0][1];
double z = coordinates[1][2] - coordinates[0][2];
return (double)(std::sqrt(x * x + y * y + z * z));
}
} // namespace verdict
This diff is collapsed.
/*=========================================================================
Module: V_GaussIntegration.hpp
Copyright 2003,2006,2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
Under the terms of Contract DE-NA0003525 with NTESS,
the U.S. Government retains certain rights in this software.
See LICENSE for details.
=========================================================================*/
/*
*
* GaussIntegration.hpp declaration of gauss integration functions
*
* This file is part of VERDICT
*
*/
#ifndef GAUSS_INTEGRATION_HPP
#define GAUSS_INTEGRATION_HPP
#include "verdict.h"
namespace VERDICT_NAMESPACE
{
#define maxTotalNumberGaussPoints 27
#define maxNumberNodes 20
#define maxNumberGaussPoints 3
#define maxNumberGaussPointsTri 6
#define maxNumberGaussPointsTet 4
struct GaussIntegration
{
void get_signs_for_node_local_coord_hex(
int node_id, double& sign_y1, double& sign_y2, double& sign_y3);
//- to get the signs for coordinates of hex nodes in the local computational space
// constructors
void initialize(int n = 2, int m = 4, int dim = 2, int tri = 0);
// manipulators
void get_gauss_pts_and_weight();
//- get gauss point locations and weights
void get_tri_rule_pts_and_weight();
//- get integration points and weights for triangular rules
void calculate_shape_function_2d_tri();
//- calculate the shape functions and derivatives of shape functions
//- at integration points for 2D triangular elements
void calculate_shape_function_2d_quad();
//- calculate the shape functions and derivatives of shape functions
//- at gaussian points for 2D quad elements
void get_shape_func(double shape_function[], double dndy1_at_gauss_pts[],
double dndy2_at_gauss_ptsp[], double gauss_weight[]);
//- get shape functions and the derivatives
void get_shape_func(double shape_function[], double dndy1_at_gauss_pts[],
double dndy2_at_gauss_pts[], double dndy3_at_gauss_pts[], double gauss_weight[]);
//- get shape functions and the derivatives for 3D elements
void calculate_derivative_at_nodes(
double dndy1_at_nodes[][maxNumberNodes], double dndy2_at_nodes[][maxNumberNodes]);
//- calculate shape function derivatives at nodes
void calculate_shape_function_3d_hex();
//- calculate shape functions and derivatives of shape functions
//- at gaussian points for 3D hex elements
void calculate_derivative_at_nodes_3d(double dndy1_at_nodes[][maxNumberNodes],
double dndy2_at_nodes[][maxNumberNodes], double dndy3_at_nodes[][maxNumberNodes]);
//- calculate shape function derivatives at nodes for hex elements
void calculate_derivative_at_nodes_2d_tri(
double dndy1_at_nodes[][maxNumberNodes], double dndy2_at_nodes[][maxNumberNodes]);
//- calculate shape function derivatives at nodes for triangular elements
void calculate_shape_function_3d_tet();
//- calculate shape functions and derivatives of shape functions
//- at integration points for 3D tet elements
void get_tet_rule_pts_and_weight();
//- get integration points and weights for tetrhedron rules
void calculate_derivative_at_nodes_3d_tet(double dndy1_at_nodes[][maxNumberNodes],
double dndy2_at_nodes[][maxNumberNodes], double dndy3_at_nodes[][maxNumberNodes]);
//- calculate shape function derivatives at nodes for tetrahedron elements
void get_node_local_coord_tet(int node_id, double& y1, double& y2, double& y3, double& y4);
//- get nodal volume coordinates for tetrahedron element
int numberGaussPoints;
int numberNodes;
int numberDims;
double gaussPointY[maxNumberGaussPoints];
double gaussWeight[maxNumberGaussPoints];
double shapeFunction[maxTotalNumberGaussPoints][maxNumberNodes];
double dndy1GaussPts[maxTotalNumberGaussPoints][maxNumberNodes];
double dndy2GaussPts[maxTotalNumberGaussPoints][maxNumberNodes];
double dndy3GaussPts[maxTotalNumberGaussPoints][maxNumberNodes];
double totalGaussWeight[maxTotalNumberGaussPoints];
int totalNumberGaussPts;
double y1Area[maxNumberGaussPointsTri];
double y2Area[maxNumberGaussPointsTri];
double y1Volume[maxNumberGaussPointsTet];
double y2Volume[maxNumberGaussPointsTet];
double y3Volume[maxNumberGaussPointsTet];
double y4Volume[maxNumberGaussPointsTet];
};
} // namespace verdict
#endif
This diff is collapsed.
/*=========================================================================
Module: V_HexMetric.hpp
Copyright 2003,2006,2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
Under the terms of Contract DE-NA0003525 with NTESS,
the U.S. Government retains certain rights in this software.
See LICENSE for details.
=========================================================================*/
/*
*
* V_HexMetric.hpp contains declarations of hex related shape quantities
*
* This file is part of VERDICT
*
*/
#ifndef VERDICT_HEX_METRIC_HPP
#define VERDICT_HEX_METRIC_HPP
#include "verdict.h"
#include <cassert>
#include <cmath>
namespace VERDICT_NAMESPACE
{
//
// Compute jacobian at each of the eight hex corner nodes
//
template <typename T>
void hex_nodal_jacobians(const T coords[24], T Jdet8x[8])
{
T x0 = coords[0];
T y0 = coords[1];
T z0 = coords[2];
T x1 = coords[3];
T y1 = coords[4];
T z1 = coords[5];
T x2 = coords[6];
T y2 = coords[7];
T z2 = coords[8];
T x3 = coords[9];
T y3 = coords[10];
T z3 = coords[11];
T x4 = coords[12];
T y4 = coords[13];
T z4 = coords[14];
T x5 = coords[15];
T y5 = coords[16];
T z5 = coords[17];
T x6 = coords[18];
T y6 = coords[19];
T z6 = coords[20];
T x7 = coords[21];
T y7 = coords[22];
T z7 = coords[23];
//
// Compute the jacobian at each node location
//
T x0y1 = x0 * y1 - x1 * y0;
T x0y2 = x0 * y2 - x2 * y0;
T x0y3 = x0 * y3 - x3 * y0;
T x0y4 = x0 * y4 - x4 * y0;
T x0y5 = x0 * y5 - x5 * y0;
T x0y7 = x0 * y7 - x7 * y0;
T x1y2 = x1 * y2 - x2 * y1;
T x1y3 = x1 * y3 - x3 * y1;
T x1y4 = x1 * y4 - x4 * y1;
T x1y5 = x1 * y5 - x5 * y1;
T x1y6 = x1 * y6 - x6 * y1;
T x2y3 = x2 * y3 - x3 * y2;
T x2y5 = x2 * y5 - x5 * y2;
T x2y6 = x2 * y6 - x6 * y2;
T x2y7 = x2 * y7 - x7 * y2;
T x3y4 = x3 * y4 - x4 * y3;
T x3y6 = x3 * y6 - x6 * y3;
T x3y7 = x3 * y7 - x7 * y3;
T x4y5 = x4 * y5 - x5 * y4;
T x4y6 = x4 * y6 - x6 * y4;
T x4y7 = x4 * y7 - x7 * y4;
T x5y6 = x5 * y6 - x6 * y5;
T x5y7 = x5 * y7 - x7 * y5;
T x6y7 = x6 * y7 - x7 * y6;
Jdet8x[0] = (-x1y3 + x1y4 - x3y4) * z0 + (x0y3 - x0y4 + x3y4) * z1 + (-x0y1 + x0y4 - x1y4) * z3 +
(x0y1 - x0y3 + x1y3) * z4;
Jdet8x[1] = (-x1y2 + x1y5 - x2y5) * z0 + (x0y2 - x0y5 + x2y5) * z1 + (-x0y1 + x0y5 - x1y5) * z2 +
(x0y1 - x0y2 + x1y2) * z5;
Jdet8x[2] = (-x2y3 + x2y6 - x3y6) * z1 + (x1y3 - x1y6 + x3y6) * z2 + (-x1y2 + x1y6 - x2y6) * z3 +
(x1y2 - x1y3 + x2y3) * z6;
Jdet8x[3] = (-x2y3 + x2y7 - x3y7) * z0 + (x0y3 - x0y7 + x3y7) * z2 + (-x0y2 + x0y7 - x2y7) * z3 +
(x0y2 - x0y3 + x2y3) * z7;
Jdet8x[4] = (-x4y5 + x4y7 - x5y7) * z0 + (x0y5 - x0y7 + x5y7) * z4 + (-x0y4 + x0y7 - x4y7) * z5 +
(x0y4 - x0y5 + x4y5) * z7;
Jdet8x[5] = (-x4y5 + x4y6 - x5y6) * z1 + (x1y5 - x1y6 + x5y6) * z4 + (-x1y4 + x1y6 - x4y6) * z5 +
(x1y4 - x1y5 + x4y5) * z6;
Jdet8x[6] = (-x5y6 + x5y7 - x6y7) * z2 + (x2y6 - x2y7 + x6y7) * z5 + (-x2y5 + x2y7 - x5y7) * z6 +
(x2y5 - x2y6 + x5y6) * z7;
Jdet8x[7] = (-x4y6 + x4y7 - x6y7) * z3 + (x3y6 - x3y7 + x6y7) * z4 + (-x3y4 + x3y7 - x4y7) * z6 +
(x3y4 - x3y6 + x4y6) * z7;
}
}
#endif
/*=========================================================================
Module: V_KnifeMetric.cpp
Copyright 2003,2006,2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
Under the terms of Contract DE-NA0003525 with NTESS,
the U.S. Government retains certain rights in this software.
See LICENSE for details.
=========================================================================*/
/*
*
* KnifeMetrics.cpp contains quality calculations for knives
*
* This file is part of VERDICT
*
*/
#include "VerdictVector.hpp"
#include "verdict.h"
namespace VERDICT_NAMESPACE
{
/* a knife element
3
_/\_
_/ | \_
0 _/ \_ 2
|\_ | ___/|
| \ __/ |
| 1\/ | |
| \ |
|_____\|_____|
4 5 6
(edge 3,5 is is a hidden line if you will)
if this is hard to visualize, consider a hex
with nodes 5 and 7 becoming the same node
*/
/*!
calculates the volume of a knife element
this is done by dividing the knife into 4 tets
and summing the volumes of each.
*/
double knife_volume(int num_nodes, const double coordinates[][3])
{
double volume = 0;
VerdictVector side1, side2, side3;
if (num_nodes == 7)
{
// divide the knife into 4 tets and calculate the volume
side1.set(coordinates[1][0] - coordinates[0][0], coordinates[1][1] - coordinates[0][1],
coordinates[1][2] - coordinates[0][2]);
side2.set(coordinates[3][0] - coordinates[0][0], coordinates[3][1] - coordinates[0][1],
coordinates[3][2] - coordinates[0][2]);
side3.set(coordinates[4][0] - coordinates[0][0], coordinates[4][1] - coordinates[0][1],
coordinates[4][2] - coordinates[0][2]);
volume = side3 % (side1 * side2) / 6;
side1.set(coordinates[5][0] - coordinates[1][0], coordinates[5][1] - coordinates[1][1],
coordinates[5][2] - coordinates[1][2]);
side2.set(coordinates[3][0] - coordinates[1][0], coordinates[3][1] - coordinates[1][1],
coordinates[3][2] - coordinates[1][2]);
side3.set(coordinates[4][0] - coordinates[1][0], coordinates[4][1] - coordinates[1][1],
coordinates[4][2] - coordinates[1][2]);
volume += side3 % (side1 * side2) / 6;
side1.set(coordinates[2][0] - coordinates[1][0], coordinates[2][1] - coordinates[1][1],
coordinates[2][2] - coordinates[1][2]);
side2.set(coordinates[3][0] - coordinates[1][0], coordinates[3][1] - coordinates[1][1],
coordinates[3][2] - coordinates[1][2]);
side3.set(coordinates[6][0] - coordinates[1][0], coordinates[6][1] - coordinates[1][1],
coordinates[6][2] - coordinates[1][2]);
volume += side3 % (side1 * side2) / 6;
side1.set(coordinates[3][0] - coordinates[1][0], coordinates[3][1] - coordinates[1][1],
coordinates[3][2] - coordinates[1][2]);
side2.set(coordinates[5][0] - coordinates[1][0], coordinates[5][1] - coordinates[1][1],
coordinates[5][2] - coordinates[1][2]);
side3.set(coordinates[6][0] - coordinates[1][0], coordinates[6][1] - coordinates[1][1],
coordinates[6][2] - coordinates[1][2]);
volume += side3 % (side1 * side2) / 6;
}
return (double)volume;
}
} // namespace verdict
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*=========================================================================
Module: verdict_config.h.in
Copyright 2003,2006,2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
Under the terms of Contract DE-NA0003525 with NTESS,
the U.S. Government retains certain rights in this software.
See LICENSE for details.
=========================================================================*/
/*! \file verdict_config.h
\brief Configuration header file for verdict library that calculates metrics for finite elements.
Also see: \ref index "Main Page"
*
* This file is part of VERDICT
*
*/
#ifndef __verdict_config_h
#define __verdict_config_h
#define VERDICT_VERSION @verdict_VERSION_FLAT@
#cmakedefine BUILD_SHARED_LIBS
#ifdef BUILD_SHARED_LIBS
# define VERDICT_SHARED_LIB
#endif
#cmakedefine VERDICT_MANGLE
#ifdef VERDICT_MANGLE
# define VERDICT_NAMESPACE @VERDICT_MANGLE_PREFIX@
#endif
#endif /* __verdict_config_h */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment