Commit c3790e16 authored by Julian Marcon's avatar Julian Marcon

Merge branch 'master' into feature/2-point-loops

parents 276c8782 6132bf3e
......@@ -30,6 +30,9 @@ v5.0.0
- Adds CFI CAD engine back-end (!864)
- Adds CFI Mesh IO support (!864)
- Cleanup of CAD system data structures (!864)
- Fix mac OSX on buildbots (!876)
- Fix error from (!826) (!876)
- Fix minor bug in ARPACK thirdparty build cmake (!874)
**NekMesh**:
- Add feature to read basic 2D geo files as CAD (!731)
......@@ -45,6 +48,8 @@ v5.0.0
- Additional curve types in GEO reader: BSpline, Circle, Ellipse (!800)
- Fix default command line argument value (!823)
- Add projection meshing module which can curve linear meshes with CAD (!826)
- Revert triangle code to ThirdParty library (!883)
- Fix coinciding nodes issue with very fine meshes (!883)
**FieldConvert**:
- Add input module for Semtex field files (!777)
......@@ -54,6 +59,7 @@ v5.0.0
- Allow explicitly setting bool options of FieldConvert modules as false (!811)
- Enable output to multiple files (!844)
- Allow using xml file without expansion tag in FieldConvert (!849)
- Add Lambda 2 vortex detection criteria (!882)
**IncNavierStokesSolver**
- Replace steady-state check based on difference of norms by check based on
......@@ -85,6 +91,9 @@ v4.4.2
- Fix sign of the viscous term in the velocity correction scheme equations in
the user guide (!856)
**FieldConvert**
- Allow passing input name with trailing separator (!879)
v4.4.1
------
**Library**
......
......@@ -245,6 +245,7 @@ INCLUDE (ThirdPartyArpack)
INCLUDE (ThirdPartyMPI)
INCLUDE (ThirdPartyVTK)
INCLUDE (ThirdPartyOCE)
INCLUDE (ThirdPartyTriangle)
INCLUDE (ThirdPartyTetGen)
INCLUDE (ThirdPartyCCM)
INCLUDE (FindCFI)
......
# Try to find OCE / OCC
# Once done this will define
#
# OCC_FOUND - system has OCC - OpenCASCADE
# OCC_INCLUDE_DIR - where the OCC include directory can be found
# OCC_LIBRARY_DIR - where the OCC library directory can be found
# OCC_LIBRARIES - Link this to use OCC
# OCC_OCAF_LIBRARIES - Link this to use OCC OCAF framework
#
# Adapted from FreeCAD: http://free-cad.sf.net
SET(TEST_ENV $ENV{OCE_ROOT})
IF(NOT DEFINED OCE_DIR AND DEFINED TEST_ENV)
FILE(GLOB OCE_DIR $ENV{OCE_ROOT}/lib/oce-*)
ENDIF()
set(TEST_ENV $ENV{OCE_ROOT})
if(NOT DEFINED OCE_DIR AND DEFINED TEST_ENV)
file(GLOB OCE_DIR $ENV{OCE_ROOT}/lib/oce-*)
endif()
SET(TEST_ENV $ENV{OCE_DIR})
IF(NOT DEFINED OCE_DIR AND DEFINED TEST_ENV)
SET(OCE_DIR $ENV{OCE_DIR})
ENDIF()
set(TEST_ENV $ENV{OCE_DIR})
if(NOT DEFINED OCE_DIR AND DEFINED TEST_ENV)
set(OCE_DIR $ENV{OCE_DIR})
endif()
SET(OCE_FIND_COMPONENTS ${OCC_LIB_LIST})
# First try to find OpenCASCADE Community Edition
if(NOT DEFINED OCE_DIR)
# Check for OSX needs to come first because UNIX evaluates to true on OSX
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(DEFINED MACPORTS_PREFIX)
find_package(OCE 0.17 QUIET HINTS ${MACPORTS_PREFIX}/Library/Frameworks)
elseif(DEFINED HOMEBREW_PREFIX)
find_package(OCE 0.17 QUIET HINTS ${HOMEBREW_PREFIX}/Cellar/oce/*)
endif()
elseif(UNIX)
set(OCE_DIR "/usr/local/share/cmake/")
endif()
endif()
find_package(OCE 0.17 QUIET)
if(OCE_FOUND)
message(STATUS "OpenCASCADE Community Edition has been found.")
#check that the OCE package has CAF modules
FIND_LIBRARY(OCC_CAF_LIBRARY TKXCAF ${OCE_INCLUDE_DIRS}/../../lib )
#First try to find OpenCASCADE Community Edition
IF(NOT DEFINED OCE_DIR)
#Check for OSX needs to come first because UNIX evaluates to true on OSX
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
IF(DEFINED MACPORTS_PREFIX)
FIND_PACKAGE(OCE 0.17 QUIET HINTS ${MACPORTS_PREFIX}/Library/Frameworks)
ELSEIF(DEFINED HOMEBREW_PREFIX)
FIND_PACKAGE(OCE 0.17 QUIET HINTS ${HOMEBREW_PREFIX}/Cellar/oce/*)
ENDIF()
ENDIF()
ENDIF()
if(OCC_CAF_LIBRARY)
set(OCC_INCLUDE_DIR ${OCE_INCLUDE_DIRS})
else()
message(STATUS "-- OCE does not have CAF libraries, will build from source.")
endif()
FIND_PACKAGE(OCE 0.17 QUIET)
else(OCE_FOUND) #look for OpenCASCADE
SET(OCC_FOUND FALSE)
FIND_PATH(OCC_INCLUDE_DIR Standard_Version.hxx
/usr/include/opencascade
/usr/local/include/opencascade
/usr/local/opt/opencascade/include
/opt/opencascade/include
/opt/opencascade/inc
)
FIND_LIBRARY(OCC_LIBRARY TKernel
/usr/lib
/usr/local/lib
/usr/local/opt/opencascade/lib
/opt/opencascade/lib
opt/local/lib
)
IF(OCE_FOUND AND OCE_ALL_FOUND)
MESSAGE(STATUS "OpenCASCADE Community Edition has been found with all required components.")
SET(OCC_INCLUDE_DIR ${OCE_INCLUDE_DIRS})
SET(OCC_FOUND TRUE)
ELSE(OCE_FOUND AND OCE_ALL_FOUND) #look for OpenCASCADE
MESSAGE(STATUS "OpenCASCADE Community Edition could not be found or has missing components.")
SET(OpenCASCADE_FIND_COMPONENTS ${OCE_FIND_COMPONENTS})
FIND_PACKAGE(OpenCASCADE 6.8 QUIET HINTS /opt/local)
if(OCC_LIBRARY)
message(STATUS "OpenCASCADE has been found.")
GET_FILENAME_COMPONENT(OCC_LIBRARY_DIR ${OCC_LIBRARY} PATH)
IF(NOT OCC_INCLUDE_DIR)
FIND_PATH(OCC_INCLUDE_DIR Standard_Version.hxx
${OCC_LIBRARY_DIR}/../inc
)
IF(OpenCASCADE_FOUND)
MESSAGE(STATUS "OpenCASCADE has been found with all required components.")
SET(OCC_INCLUDE_DIR ${OpenCASCADE_INCLUDE_DIR})
SET(OCC_FOUND TRUE)
ELSE()
MESSAGE(STATUS "OpenCASCADE could not be found or has missing components.")
ENDIF()
endif(OCC_LIBRARY)
endif(OCE_FOUND)
if(OCC_INCLUDE_DIR)
file(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MAJOR
REGEX "#define OCC_VERSION_MAJOR.*"
)
string(REGEX MATCH "[0-9]+" OCC_MAJOR ${OCC_MAJOR})
file(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MINOR
REGEX "#define OCC_VERSION_MINOR.*"
)
string(REGEX MATCH "[0-9]+" OCC_MINOR ${OCC_MINOR})
file(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MAINT
REGEX "#define OCC_VERSION_MAINTENANCE.*"
)
string(REGEX MATCH "[0-9]+" OCC_MAINT ${OCC_MAINT})
ENDIF(OCE_FOUND AND OCE_ALL_FOUND)
set(OCC_VERSION_STRING "${OCC_MAJOR}.${OCC_MINOR}.${OCC_MAINT}")
endif(OCC_INCLUDE_DIR)
IF(OCC_FOUND)
FILE(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MAJOR
REGEX "#define OCC_VERSION_MAJOR.*")
STRING(REGEX MATCH "[0-9]+" OCC_MAJOR ${OCC_MAJOR})
FILE(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MINOR
REGEX "#define OCC_VERSION_MINOR.*")
STRING(REGEX MATCH "[0-9]+" OCC_MINOR ${OCC_MINOR})
FILE(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MAINT
REGEX "#define OCC_VERSION_MAINTENANCE.*")
STRING(REGEX MATCH "[0-9]+" OCC_MAINT ${OCC_MAINT})
# handle the QUIETLY and REQUIRED arguments and set OCC_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OCC REQUIRED_VARS OCC_INCLUDE_DIR VERSION_VAR OCC_VERSION_STRING)
SET(OCC_VERSION_STRING "${OCC_MAJOR}.${OCC_MINOR}.${OCC_MAINT}")
if(OCC_FOUND)
set(OCC_LIBRARIES
TKFillet
TKMesh
TKernel
TKG2d
TKG3d
TKMath
TKIGES
TKSTL
TKShHealing
TKXSBase
TKBool
TKBO
TKBRep
TKTopAlgo
TKGeomAlgo
TKGeomBase
TKOffset
TKPrim
TKSTEP
TKSTEPBase
TKSTEPAttr
TKHLR
TKFeat
TKXCAF
TKXDESTEP
)
if(OCC_VERSION_STRING VERSION_LESS 6.8)
MESSAGE(SEND_ERROR "OCC version too low")
endif(OCC_VERSION_STRING VERSION_LESS 6.8)
message(STATUS "-- Found OCE/OpenCASCADE with OCC version: ${OCC_VERSION_STRING}")
endif(OCC_FOUND)
IF(OCC_VERSION_STRING VERSION_LESS 6.8)
MESSAGE(STATUS "OCC version too low, will build from source")
SET(OCC_FOUND FALSE)
ELSE()
MESSAGE(STATUS "-- Found OCE/OpenCASCADE with OCC version: ${OCC_VERSION_STRING}")
SET(OCC_LIBRARIES ${OCE_FIND_COMPONENTS})
ENDIF()
ENDIF(OCC_FOUND)
......@@ -24,44 +24,41 @@ IF (NEKTAR_USE_ARPACK)
MESSAGE(FATAL_ERROR "Could not find or build Arpack")
ENDIF()
ENDIF()
ENDIF()
OPTION(THIRDPARTY_BUILD_ARPACK "Build arpack libraries from ThirdParty."
${BUILD_ARPACK})
IF(THIRDPARTY_BUILD_ARPACK)
INCLUDE(ExternalProject)
OPTION(THIRDPARTY_BUILD_ARPACK "Build arpack libraries from ThirdParty."
${BUILD_ARPACK})
EXTERNALPROJECT_ADD(
arpack-ng-1.0
PREFIX ${TPSRC}
URL ${TPURL}/arpack-ng.tar.gz
URL_MD5 "26cb30275d24eb79c207ed403e794736"
STAMP_DIR ${TPBUILD}/stamp
DOWNLOAD_DIR ${TPSRC}
SOURCE_DIR ${TPSRC}/arpack-ng-1.0
BINARY_DIR ${TPBUILD}/arpack-ng-1.0
TMP_DIR ${TPBUILD}/arpack-ng-1.0-tmp
INSTALL_DIR ${TPDIST}
CONFIGURE_COMMAND ${CMAKE_COMMAND}
-G ${CMAKE_GENERATOR}
-DCMAKE_Fortran_COMPILER:FILEPATH=${CMAKE_Fortran_COMPILER}
-DCMAKE_INSTALL_PREFIX:PATH=${TPDIST}
-DCMAKE_INSTALL_LIBDIR:PATH=${TPDIST}/lib
-DBUILD_SHARED_LIBS:STRING=ON
${TPSRC}/arpack-ng-1.0
)
IF(THIRDPARTY_BUILD_ARPACK)
INCLUDE(ExternalProject)
SET(ARPACK_LIBRARY arpack)
EXTERNALPROJECT_ADD(
arpack-ng-1.0
PREFIX ${TPSRC}
URL ${TPURL}/arpack-ng.tar.gz
URL_MD5 "26cb30275d24eb79c207ed403e794736"
STAMP_DIR ${TPBUILD}/stamp
DOWNLOAD_DIR ${TPSRC}
SOURCE_DIR ${TPSRC}/arpack-ng-1.0
BINARY_DIR ${TPBUILD}/arpack-ng-1.0
TMP_DIR ${TPBUILD}/arpack-ng-1.0-tmp
INSTALL_DIR ${TPDIST}
CONFIGURE_COMMAND ${CMAKE_COMMAND}
-G ${CMAKE_GENERATOR}
-DCMAKE_Fortran_COMPILER:FILEPATH=${CMAKE_Fortran_COMPILER}
-DCMAKE_INSTALL_PREFIX:PATH=${TPDIST}
-DCMAKE_INSTALL_LIBDIR:PATH=${TPDIST}/lib
-DBUILD_SHARED_LIBS:STRING=ON
${TPSRC}/arpack-ng-1.0
)
LINK_DIRECTORIES(${TPDIST}/lib)
THIRDPARTY_LIBRARY(ARPACK_LIBRARY SHARED arpack DESCRIPTION "ARPACK library")
LINK_DIRECTORIES(${TPDIST}/lib)
INCLUDE_DIRECTORIES(${TPDIST}/include)
INCLUDE_DIRECTORIES(${TPDIST}/include)
MESSAGE(STATUS "Build arpack: ${TPDIST}/${LIB_DIR}/lib${ARPACK_LIBRARY}.so")
ELSE()
ADD_CUSTOM_TARGET(arpack-ng-1.0 ALL)
MESSAGE(STATUS "Build arpack: ${ARPACK_LIBRARY}")
ELSE()
ADD_CUSTOM_TARGET(arpack-ng-1.0 ALL)
ENDIF()
ENDIF()
......@@ -7,6 +7,36 @@
########################################################################
IF(NEKTAR_USE_MESHGEN)
#required opencascade libraries
SET(OCC_LIB_LIST
TKFillet
TKMesh
TKernel
TKG2d
TKG3d
TKMath
TKIGES
TKSTL
TKShHealing
TKXSBase
TKBool
TKBO
TKBRep
TKTopAlgo
TKGeomAlgo
TKGeomBase
TKOffset
TKPrim
TKSTEP
TKSTEPBase
TKSTEPAttr
TKHLR
TKFeat
TKXCAF
TKLCAF
TKXDESTEP
)
# Try to find installed version of OpenCascade
INCLUDE(FindOCC)
......@@ -22,39 +52,6 @@ IF(NEKTAR_USE_MESHGEN)
IF (THIRDPARTY_BUILD_OCE)
INCLUDE(ExternalProject)
SET(OCC_LIBRARIES_TMP
TKFillet
TKMesh
TKernel
TKG2d
TKG3d
TKMath
TKIGES
TKSTL
TKShHealing
TKXSBase
TKBool
TKBO
TKBRep
TKTopAlgo
TKGeomAlgo
TKGeomBase
TKOffset
TKPrim
TKSTEP
TKSTEPBase
TKSTEPAttr
TKHLR
TKFeat
TKXCAF
TKXDESTEP
)
FOREACH(OCC_LIB ${OCC_LIBRARIES_TMP})
LIST(APPEND OCC_LIBRARIES ${TPDIST}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}${OCC_LIB}${CMAKE_SHARED_LIBRARY_SUFFIX})
ENDFOREACH()
UNSET(OCC_LIBRARIES_TMP)
IF(WIN32)
MESSAGE(SEND_ERROR "Cannot currently use OpenCascade with Nektar++ on Windows")
ENDIF()
......@@ -86,12 +83,12 @@ IF(NEKTAR_USE_MESHGEN)
DEPENDEES install)
ENDIF()
THIRDPARTY_LIBRARY(OCC_LIBRARIES SHARED ${OCC_LIB_LIST} DESCRIPTION "OpenCascade libs")
SET(OCC_INCLUDE_DIR ${TPDIST}/include/oce CACHE FILEPATH "OCC include" FORCE)
MESSAGE(STATUS "Build OpenCascade community edition: ${TPDIST}/lib")
LINK_DIRECTORIES(${TPDIST}/lib)
INCLUDE_DIRECTORIES(${TPDIST}/include/oce)
ELSE()
ADD_CUSTOM_TARGET(oce-0.17 ALL)
SET(OPENCASCADE_CONFIG_INCLUDE_DIR ${OCC_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${OCC_INCLUDE_DIR})
ENDIF()
ENDIF()
INCLUDE_DIRECTORIES(${OCC_INCLUDE_DIR})
########################################################################
#
# ThirdParty configuration for Nektar++
#
# TRIANGLE
#
########################################################################
IF(NEKTAR_USE_MESHGEN)
SET(BUILD_TRIANGLE ON)
OPTION(THIRDPARTY_BUILD_TRIANGLE
"Build Triangle library from ThirdParty." ${BUILD_TRIANGLE})
IF (THIRDPARTY_BUILD_TRIANGLE)
INCLUDE(ExternalProject)
EXTERNALPROJECT_ADD(
triangle-1.6
PREFIX ${TPSRC}
URL ${TPURL}/triangle.zip
URL_MD5 357cb7107f51f3f89940c47435d4fa49
STAMP_DIR ${TPBUILD}/stamp
DOWNLOAD_DIR ${TPSRC}
SOURCE_DIR ${TPSRC}/triangle-1.6
BINARY_DIR ${TPBUILD}/triangle-1.6
TMP_DIR ${TPBUILD}/triangle-1.6-tmp
INSTALL_DIR ${TPDIST}
CONFIGURE_COMMAND ${CMAKE_COMMAND}
-G ${CMAKE_GENERATOR}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX:PATH=${TPDIST}
${TPSRC}/triangle-1.6
)
THIRDPARTY_LIBRARY(TRIANGLE_LIBRARY STATIC triangle
DESCRIPTION "Triangle library")
SET(TRIANGLE_INCLUDE_DIR ${TPDIST}/include CACHE FILEPATH
"Triangle include" FORCE)
MESSAGE(STATUS "Build Triangle: ${TRIANGLE_LIBRARY}")
SET(TRIANGLE_CONFIG_INCLUDE_DIR ${TPINC})
ELSE()
ADD_CUSTOM_TARGET(triangle-1.6 ALL)
MESSAGE(STATUS "Found Triangle: ${TRIANGLE_LIBRARY}")
SET(TRIANGLE_CONFIG_INCLUDE_DIR ${TRIANGLE_INCLUDE_DIR})
ENDIF (THIRDPARTY_BUILD_TRIANGLE)
MARK_AS_ADVANCED(TRIANGLE_LIBRARY)
MARK_AS_ADVANCED(TRIANGLE_INCLUDE_DIR)
INCLUDE_DIRECTORIES(${TRIANGLE_INCLUDE_DIR})
ENDIF(NEKTAR_USE_MESHGEN)
......@@ -155,6 +155,7 @@ Specifically, FieldConvert has these additional functionalities
\begin{enumerate}
\item \inltt{C0Projection}: Computes the C0 projection of a given output file;
\item \inltt{QCriterion}: Computes the Q-Criterion for a given output file;
\item \inltt{L2Criterion}: Computes the Lambda 2 Criterion for a given output file;
\item \inltt{addcompositeid}: Adds the composite ID of an element as an additional field;
\item \inltt{addFld}: Sum two .fld files;
\item \inltt{combineAvg}: Combine two \nekpp binary output (.chk or .fld) field file containing averages of fields (and
......@@ -250,6 +251,21 @@ to visualise the result either in Tecplot, Paraview or VisIt.
%
%
\subsection{Calculate $\lambda_2$: \textit{L2Criterion} module}
To perform the $\lambda_2$ vortex detection calculation and obtain an output
data containing the values of the $\lambda_2$ eigenvalue, the user can run
%
\begin{lstlisting}[style=BashInputStyle]
FieldConvert -m L2Criterion test.xml test.fld test-L2Crit.fld
\end{lstlisting}
%
where the file \inltt{test-L2Crit.fld} can be processed in a similar
way as described in section \ref{s:utilities:fieldconvert:sub:convert}
to visualise the result either in Tecplot, Paraview or VisIt.
%
%
%
\subsection{Add composite ID: \textit{addcompositeid} module}
When dealing with a geometry that has many surfaces, we need to identify the
composites to assign boundary conditions. To assist in this, FieldConvert has a
......
......@@ -35,6 +35,7 @@ SET(FieldUtilsHeaders
ProcessModules/ProcessInterpPtsToPts.h
ProcessModules/ProcessIsoContour.h
ProcessModules/ProcessJacobianEnergy.h
ProcessModules/ProcessL2Criterion.h
ProcessModules/ProcessMapping.h
ProcessModules/ProcessNumModes.h
ProcessModules/ProcessMeanMode.h
......@@ -88,6 +89,7 @@ SET(FieldUtilsSources
ProcessModules/ProcessInterpPtsToPts.cpp
ProcessModules/ProcessIsoContour.cpp
ProcessModules/ProcessJacobianEnergy.cpp
ProcessModules/ProcessL2Criterion.cpp
ProcessModules/ProcessMapping.cpp
ProcessModules/ProcessNumModes.cpp
ProcessModules/ProcessMeanMode.cpp
......
////////////////////////////////////////////////////////////////////////////////
//
// File: ProcessL2Criterion.cpp
//
// For more information, please see: http://www.nektar.info/
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Computes Lambda 2 Criterion field.
//
////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
using namespace std;
#include "ProcessL2Criterion.h"
#include <LibUtilities/BasicUtils/SharedArray.hpp>
namespace Nektar
{
namespace FieldUtils
{
ModuleKey ProcessL2Criterion::className =
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "L2Criterion"), ProcessL2Criterion::create,
"Computes Lambda 2 Criterion.");
ProcessL2Criterion::ProcessL2Criterion(FieldSharedPtr f) : ProcessModule(f)
{
}
ProcessL2Criterion::~ProcessL2Criterion()
{
}
/**
* @brief Calculates eigenvalues of a 3x3 Symmetric matrix.
*
* @param d1, d2, d3 - matrix diagonal entries at [0,0], [1,1] and [2,2]
* @param a - matrix value at [0,1] and [1,0]
* @param b - matrix value at [0,2] and [2,0]
* @param c - matrix value at [1,2] and [2,1]
* @param l1, l2, l3 the computed eigenvalues, ordered l3 >= l2 >= l1
*/
void MatSymEVals(NekDouble d1, NekDouble d2, NekDouble d3, NekDouble a,
NekDouble b, NekDouble c, NekDouble &l1, NekDouble &l2,
NekDouble &l3)
{
NekDouble p = a * a + b * b + c * c;
if (p == 0)
{
l1 = d1;
l2 = d2;
l3 = d3;
if (l1 > l3)
{
swap(l1, l3);
}
if (l1 > l2)
{
swap(l1, l2);
}
if (l2 > l3)
{
swap(l2, l3);
}
}
else
{
NekDouble q = (d1 + d2 + d3) / 3.0;
p = (d1 - q) * (d1 - q) + (d2 - q) * (d2 - q) + (d3 - q) * (d3 - q) +
2.0 * p;
p = sqrt(p / 6.0);
NekDouble r =
-0.5 *
(a * a * d3 - a * a * q - 2.0 * a * b * c + b * b * d2 - b * b * q +
c * c * d1 - c * c * q - d1 * d2 * d3 + d1 * d2 * q + d1 * d3 * q -
d1 * q * q + d2 * d3 * q - d2 * q * q - d3 * q * q + q * q * q) /
(p * p * p);
NekDouble phi = 0;
if (r <= -1)
{
phi = M_PI / 3.0;
}
else if (r >= 1)
{
phi = 0.0;
}
else
{
phi = acos(r) / 3.0;
}
// the eigenvalues satisfy eig3 >= eig2 >= eig1
l3 = q + 2.0 * p * cos(phi);
l1 = q + 2.0 * p * cos(phi + (2.0 * M_PI / 3.0));
// since trace(A) = eig1 + eig2 + eig3
l2 = 3.0 * q - l1 - l3;
}
}
void ProcessL2Criterion::Process(po::variables_map &vm)
{
auto nfields = m_f->m_variables.size();
m_f->m_variables.push_back("L2");
// Skip in case of empty partition
if (m_f->m_exp[0]->GetNumElmts() == 0)
{
return;
}
int i, s;
int expdim = m_f->m_graph->GetMeshDimension();
int spacedim = expdim + (m_f->m_numHomogeneousDir);
ASSERTL0(
spacedim == 3,