Skip to content
Snippets Groups Projects
Commit afa322f8 authored by Jingtian Zhou's avatar Jingtian Zhou Committed by Dave Moxey
Browse files

New feature for ProcessJac in NekMesh. Output Jacobian information on the...

New feature for ProcessJac in NekMesh. Output Jacobian information on the screen and into the log file
parent ce6e4eed
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,7 @@ v5.7.0
**NekMesh**
- Added revolve module (!1825)
- Extend quality measures in ProcessJac and add histogram generation(!1751)
**FieldConvert**
- Add vortexinducedvelocity module to compute the vortex-induced velocity (!1824)
......
docs/user-guide/utilities/img/ProcessJac_histo.png

29.1 KiB

docs/user-guide/utilities/img/ProcessJac_output.png

240 KiB

docs/user-guide/utilities/img/ProcessJac_quality.png

46.3 KiB

......@@ -546,7 +546,7 @@ NekMesh -m extract:surf=2,3-5:detectbnd Mesh.xml output.xml
\end{lstlisting}
which will produce new composites for the extracted boundary.
\subsection{Negative Jacobian detection}
\subsection{Negative Jacobian detection and histogram visualisation}
To detect elements with negative Jacobian determinant, use the \inltt{jac}
module:
......@@ -562,13 +562,41 @@ the \inltt{list} option:
NekMesh -m jac:list Mesh.xml output.xml
\end{lstlisting}
%
and to extract the elements for the purposes of visualisation within the domain,
use the \inltt{extract} boolean parameter:
To extract the elements whose Jacobian is under a specific value for the purposes of visualisation within the domain,
use the \inltt{extract} boolean parameter. The \inltt{value} should be a number below 1.0 and is 0.0 by default. This means if \inltt{extract} is set by user with no value, the output mesh file will only have invalid mesh elements:
%
\begin{lstlisting}[style=BashInputStyle]
NekMesh -m jac:extract Mesh.xml MeshWithNegativeElements.xml
NekMesh -m jac:extract=value Mesh.xml MeshWithNegativeElements.xml
\end{lstlisting}
To show the histogram of Jacobian on the screen, use the \inltt{histo} parameter.
\begin{lstlisting}[style=BashInputStyle]
NekMesh -m jac:histo=value1,value2,value3:quality:detail:histofile=filename Mesh.xml output.xml
\end{lstlisting}
The \inltt{histo} takes 3 input values: The maximum value shown on the histogram, the number of positive bins on the histogram and the number of negative bins. Each value is separated with a comma. By default the values are: 1.0,10,1. This means by default the histogram will have 10 positive bins between (0.0, 1.0) with an interval 0.1, and will have 1 negative bins which shows all the invalid elememnts. An example can be found below in figure \ref{fig:util:mesh:histo} (a).
This command \inltt{histo} also generates a text file called "jacs.txt" which contains the information of each element in the histogram. The name of the file can be changed by using the command \inltt{histofile}. The information in this text file are: Element ID, Jacobian value, element type, if this element is a boundary element, the boundary edge/face ID, vertex coordinates and neighbor element ID will also be included. Note that only elements whose Jacobian is smaller than "value1" will be counted, and they will be outputted in the histogram and text file. If command \inltt{detail} is added, the composite ID and name of each element will also be outputted into the text file. An example is shown in figure \ref{fig:util:mesh:histo} (c).
The command \inltt{quality} is an option which show the percentage of each bin of the histogram. The results of \inltt{quality} always match the histogram. An example is shown in figure \ref{fig:util:mesh:histo} (b).
An example with the following command is shown in figure \ref {fig:util:mesh:histo}. The results of \inltt{quality} and text file always correspond to the histogram.
\begin{lstlisting}[style=BashInputStyle]
NekMesh -m jac:histo=0.9,3,2:quality:detail Mesh.xml output.xml
\end{lstlisting}
\begin{figure}[!htbp]
\begin{center}
\includegraphics[width = 0.47 \textwidth]{img/ProcessJac_histo.png}
\includegraphics[width = 0.47 \textwidth]{img/ProcessJac_quality.png}
\includegraphics[width = 1.0 \textwidth]{img/ProcessJac_output.png}
\caption{(a) Results of option "histo": histogram shown on the screen, (b) Results of option "quality", (c) Part of the text file "jacs.txt"}
\label{fig:util:mesh:histo}
\end{center}
\end{figure}
To turn off curvature associated with negative jacobians one can try to use the
\inltt{linearise} module:
\begin{lstlisting}[style=BashInputStyle]
......
This diff is collapsed.
......@@ -49,7 +49,6 @@ namespace Nektar::NekMesh
class ProcessJac : public NekMesh::ProcessModule
{
public:
/// Creates an instance of this class
static std::shared_ptr<Module> create(NekMesh::MeshSharedPtr m)
{
return MemoryManager<ProcessJac>::AllocateSharedPtr(m);
......@@ -66,6 +65,89 @@ public:
{
return "ProcessJac";
}
/**
* @brief Outputing space in the jac.txt using std::setw().
*/
enum
{
ElementID = 10,
Jac = 15,
type = 15,
Boundary_edge_ID = 20,
VertexID = 15,
Boundary_face_ID = 20,
EdgeID = 10,
CoordX = 15,
CoordY = 15,
CoordZ = 15,
CompositeName = 15,
CompositeID = 15,
NeighborElID = 30
};
typedef struct
{
NekDouble Jac;
ElementSharedPtr El;
} element_reorder;
private:
/// The maximum value shown on the on-screen histogram. Defined by the user
/// in the first value of "histo".
NekDouble m_histo_max_value;
/// The number of bins with positive Jacobians of the histogram shown on the
/// screen. Defined by the user in the second value of "histo".
int m_ScalePos;
/// The number of bins with negative Jacobians of the histogram shown on the
/// screen. Defined by the user in the third value of "histo"
int m_ScaleNeg;
/// The interval of the bin of the histogram shown on the screen, which is
/// calculated by m_histo_max_value/m_ScalePos
NekDouble m_interval;
/**
* @brief Get the coordinates of the boundary vertices of the boundary
* face/edge and export them to the text file.
*
* @param el SharedPointer to the evaluated element.
* @param output_file The file where information is writtern to.
* @param detail True also gets and writes the composite name the element
* boundary is on.
*/
void GetBoundaryCoordinate(const ElementSharedPtr &el,
std::ofstream &output_file, bool detail);
/**
* @brief Get the composite name and ID of a boundary element, which can be
* further exported into a text file.
*
* @param el SharedPointer to the evaluated element.
* @param CompositeNamed The composite name of the boundary element.
* @param CompositeID The ID of the composite where the boundary element
* lies on.
* @return False if the imported mesh does not set name for
* composites.
*/
bool GetCompositeName(const ElementSharedPtr &el,
std::string &CompositeNamed,
unsigned int &CompositeID);
/**
* @brief Output histogram of scaled Jacobian on the screen.
*
* @param histo Array which contains the number of elements in each interval
* between 0.0 and 1.0.
*/
void GetHistogram(const Array<OneD, NekDouble> &histo);
/**
* @brief Check quality based on scaled Jacobians. The scaled Jacobian is
* between 0.0 to 1.0, and is divided to 10 columns (by default, this number
* is the same as that in the function GetHistogram), this function shows
* the number of elements in each columns
*
* @param QuaHisto Array which contains the number of elements in each
* interval between 0.0 and 1.0.
*/
void Qualitycheck(Array<OneD, NekDouble> QuaHisto);
};
} // namespace Nektar::NekMesh
......
......@@ -5,6 +5,7 @@ ADD_UTILITIES_EXECUTABLE(NekMesh COMPONENT nekmesh
DEPENDS libNekMesh)
# Nektar++
ADD_NEKTAR_TEST(Nektar++/3d_sphere)
ADD_NEKTAR_TEST(Nektar++/bl_quad)
ADD_NEKTAR_TEST(Nektar++/bl_tube)
ADD_NEKTAR_TEST(Nektar++/extract_curved_edge)
......
<?xml version="1.0" encoding="utf-8" ?>
<test>
<description>Test quality of half sphere</description>
<executable>NekMesh</executable>
<parameters>-m jac:list:quality 3d_sphere.xml 3d_sphere-out.xml:xml:test</parameters>
<files>
<file description="Input File">3d_sphere.xml</file>
</files>
<metrics>
<metric type="regex" id="1">
<regex>.*Integration of Jacobian: ([0-9]*\.[0-9]+)%?</regex>
<matches>
<match>
<field id="0" tolerance="2e-2">99.89</field>
</match>
</matches>
</metric>
</metrics>
</test>
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment