Commit 9e1818c3 authored by frey_m's avatar frey_m
Browse files

AMR test case:

- Doxygen documentation

modified:   Tagging_nd.f90
new file:   analyse.py
modified:   error.cpp
modified:   vis_iter.py
modified:   visualize.py
parent 2daa09a7
!> @file Tagging_nd.f90
!! @author Weiqun Zhang
!! @date October 2016, LBNL
!! @details This Fortran routine is used for tagging
!! the cells at a level for refinement.
!! In case of refinement a cell of the tagbox is
!! marked "set" otherwise "clear".
!! @brief Fortran routine for tagging cells.
! ::: -----------------------------------------------------------
! ::: This routine will tag high error cells based on the state
......@@ -17,6 +25,19 @@
! ::: level => refinement level of this array
! ::: -----------------------------------------------------------
!> Called by AmrOpal::ErrorEst.
!! @param tag integer tag array
!! @param tag_lo lower index extent of tag array
!! @param tag_hi upper index extent of tag array
!! @param state is the state array
!! @param set is the integer value to tag cell fo refinement
!! @param clear is the integer value to untag a cell
!! @param lo is the lower left corner of the work region we are allowed to change
!! @param hi is the upper right corner of the work region we are allowed to change
!! @param dx is the cell size
!! @param problo is the physical location of the lower left corner of the problem domain
!! @param time is the problem evolution time
!! @param level is the refinement level of this array
subroutine state_error(tag,tag_lo,tag_hi, &
state,state_lo,state_hi, &
set,clear,&
......
##
# @file analyse.py
# @author Matthias Frey
# @date 26. Oct. 2016
# @details The files generated by error.cpp can be visualized using this script.
# It plots the number of levels vs. the Euclidean error norm where the
# error is computed between the single- and multi-level solution.
# @pre Environment variable OPAL_BUILD has to be set.
# @brief Plot the Euclidean error norm vs. the level of refinement
import numpy as np
import os
import matplotlib.pyplot as plt
## Absolute path to OPAL build directory
opal = os.environ['OPAL_BUILD']
##
# Create an error plot
# @param filename is the absolute path
# @param xlab is the label on the x-axis
# @param ylab is the label on the y-axis
def doPlot(filename, xlab, ylab):
# error with respect to single-level solve.
nLevels, l2err = np.loadtxt(filename, unpack=True)
plt.figure()
plt.plot(nLevels, l2err, "-o")
plt.xlabel(xlab)
plt.ylabel(ylab)
plt.show()
doPlot(opal + "/ippl/test/AMR/l2_error_NOPARTICLES.dat",
'#levels', r'$L_{2}$-error')
doPlot(opal + "/ippl/test/AMR/l2_error_UNIFORM.dat",
'#levels', r'$L_{2}$-error')
doPlot(opal + "/ippl/test/AMR/l2_error_GAUSSIAN.dat",
'#levels', r'$L_{2}$-error')
......@@ -84,7 +84,7 @@ int main(int argc, char* argv[]) {
ParallelDescriptor::Barrier();
if ( ParallelDescriptor::MyProc() == 0 && solved) {
std::ofstream out("l2_error.dat", std::ios::app);
std::ofstream out("l2_error_" + std::string(argv[6]) + ".dat", std::ios::app);
out << nLevels << " " << l2error << std::endl;
out.close();
}
......
# Author: Matthias Frey
# Date: 19. Oct. 2016, LBNL
##
# @file vis_iter.py
# @author Matthias Frey
# @date 19. Oct. 2016, LBNL
#
# Script for visualizing the outpuf files
# of iterative.cpp
# It plots the potential (centered in longitudinal direction)
# and the elecric field
# components (centered)
# @pre Environment variable OPAL_BUILD has to be set.
# @details Script for visualizing the output files of iterative.cpp.
# It plots the potential (centered in longitudinal direction)
# and the elecric field components (centered)
# @brief Plot potential and electric field of iterative.cpp
import matplotlib.pyplot as plt
import numpy as np
......@@ -37,6 +39,9 @@ xi = np.extract(k == h, i)
yi = np.extract(k == h, j)
phi = np.extract(k == h, phi)
print max(phi)
print min(phi)
doPlot(xi, yi, phi, 'grid in x', 'grid in y', r'$\phi$', 221, 'Density Plot',
......
# Matthias Frey
# 14. October 2016, LBNL
##
# @file visualize.py
# @author Matthias Frey
# @date 14. October 2016, LBNL
#
# Plot the electric self-field, density and self-field
# @pre Environment variable OPAL_BUILD has to be set.
# @details Plot the electric self-field, density and self-field
# potential using the yt framework.
# 1. mpirun -np #cores testSolver
# 2. python visualize.py (make sure you sourced the yt directory $YT_DIR/yt-x86_64/bin/activate)
# @brief Slice plots of plotfiles generated by writePlotFile.H
import os
import yt
......
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