Commit 19c452f2 authored by Steven Walton's avatar Steven Walton

Almost there. Need to figure out derivative. Talk to Sam tomorrow

parent 3b2fb5c8
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//
// Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2018 UT-Battelle, LLC.
// Copyright 2018 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_exec_cellmetrics_CellDimensionMetric_h
#define vtk_m_exec_cellmetrics_CellDimensionMetric_h
/*
* Mesh quality metric functions that compute the dimension of mesh cells. The
* Dimension metric is defined as the volume divided by two times the gradient
* of the volume.
*
* This metric was designed in context of Sandia's Pronto code for stable time
* step calculation.
*
* These metric computations are adapted from the VTK implementation of the
* Verdict library, which provides a set of mesh/cell metrics for evaluating the
* geometric qualities of regions of mesh spaces.
*
* See: The Verdict Library Reference Manual (for per-cell-type metric formulae)
* See: vtk/ThirdParty/verdict/vtkverdict (for VTK code implementation of this
* metric)
*/
#include "vtkm/CellShape.h"
#include "vtkm/CellTraits.h"
#include "vtkm/VecTraits.h"
#include "vtkm/VectorAnalysis.h"
#include "vtkm/exec/FunctorBase.h"
#include "vtkm/exec/CellMeasure.h"
#define UNUSED(expr) (void)(expr);
namespace vtkm
{
namespace exec
{
namespace cellmetrics
{
using FloatType = vtkm::FloatDefault;
// ========================= Unsupported cells ==================================
// Dimension is only defined for Hexahedral cell typesk
template <typename OutType, typename PointCoordVecType, typename CellShapeType>
VTKM_EXEC OutType CellDiagonalRatioMetric(const vtkm::IdComponent& numPts,
const PointCoordVecType& pts,
CellShapeType shape,
const vtkm::exec::FunctorBase&)
{
UNUSED(numPts);
UNUSED(pts);
UNUSED(shape);
return OutType(0.0);
}
template <typename OutType, typename PointCoordVecType>
VTKM_EXEC OutType CellDimensionMetric(const vtkm::IdComponent& numPts,
const PointCoordVecType& pts,
vtkm::CellShapeTagHexahedron,
const vtkm::exec::FunctorBase& worklet)
{
FloatType volume = vtkm::exec::CellMeasure(numPts,
pts,
vtkm::CellShapeTagHexahedron,
worklet);
FloatType grad_volume; // Find what the derivative of a vector is
/*
* 1./64. * (vtkm::Cross(da/dt, b) + vtkm::Cross(a, db/dt)) *
* (vtkm::Dot(a,dc/dt) + vtkm::Dot(vtkm::Cross(da/dt,b) +
* vtkm::Cross(a,db/dt),c));
*/
if (grad_volume == 0.)
{
worklet.RaiseError("Zero division error! Gradient of volume is zero.");
return OutType(0.0);
}
OutType q = volume / (2. * grad_volume);
return q;
}
#endif // vtk_m_exec_cellmetrics_CellDimensionMetric_h
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment