Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding more automatic tests #347

Merged
merged 12 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ jobs:
export OMPI_ALLOW_RUN_AS_ROOT=1
export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1

cd tests/automatic_tests
cd automatic_tests
python3 run_automatic_tests.py

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ main
integratedFields.txt
output.txt
error.txt
CTestCostData.txt

# Checkpoint/restart files
restart.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ if(EXISTS "nucleation.cc")
endif()

# Set location of files
include_directories(${CMAKE_SOURCE_DIR}/../../../include)
include_directories(${CMAKE_SOURCE_DIR}/../../../src)
include_directories(${CMAKE_SOURCE_DIR}/../../include)
include_directories(${CMAKE_SOURCE_DIR}/../../src)
include_directories(${CMAKE_SOURCE_DIR})

# Set the location of the main.cc file
Expand All @@ -154,12 +154,12 @@ if(${PRISMS_PF_BUILD_DEBUG} STREQUAL "ON")
add_executable(main_debug ${TARGET_SRC})
set_property(TARGET main_debug PROPERTY OUTPUT_NAME main-debug)
deal_ii_setup_target(main_debug DEBUG)
target_link_libraries(main_debug ${CMAKE_SOURCE_DIR}/../../../libprisms-pf-debug.a)
target_link_libraries(main_debug ${CMAKE_SOURCE_DIR}/../../libprisms-pf-debug.a)
endif()

if(${PRISMS_PF_BUILD_RELEASE} STREQUAL "ON")
add_executable(main_release ${TARGET_SRC})
set_property(TARGET main_release PROPERTY OUTPUT_NAME main)
deal_ii_setup_target(main_release RELEASE)
target_link_libraries(main_release ${CMAKE_SOURCE_DIR}/../../../libprisms-pf-release.a)
target_link_libraries(main_release ${CMAKE_SOURCE_DIR}/../../libprisms-pf-release.a)
endif()
77 changes: 77 additions & 0 deletions automatic_tests/CHAC_anisotropyRegularized/parameters.prm
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# =================================================================================
# Set the number of dimensions (2 or 3 for a 2D or 3D calculation)
# =================================================================================
set Number of dimensions = 2

# =================================================================================
# Set the length of the domain in all three dimensions
# (Domain size Z ignored in 2D)
# =================================================================================
set Domain size X = 100
set Domain size Y = 100
set Domain size Z = 100

# =================================================================================
# Set the element parameters
# =================================================================================
set Subdivisions X = 1
set Subdivisions Y = 1
set Subdivisions Z = 1

set Refine factor = 7

set Element degree = 1

# =================================================================================
# Set the adaptive mesh refinement parameters
# =================================================================================
set Mesh adaptivity = true

set Max refinement level = 7
set Min refinement level = 4

set Steps between remeshing operations = 1000

subsection Refinement criterion: n
set Criterion type = VALUE
set Value lower bound = 0.001
set Value upper bound = 0.999
end

# =================================================================================
# Set the time step parameters
# =================================================================================
set Time step = 5.0e-2

set Number of time steps = 5000

# =================================================================================
# Set the boundary conditions
# =================================================================================
set Boundary condition for variable c = NATURAL
set Boundary condition for variable n = NATURAL
set Boundary condition for variable biharm = NATURAL

# =================================================================================
# Set the model constants
# =================================================================================
# The CH mobility, McV in equations.h
set Model constant McV = 1.0, DOUBLE

# The AC mobility, MnV in equations.h
set Model constant MnV = 0.1, DOUBLE

# Anisotropy parameter
set Model constant epsilonM = 0.2, DOUBLE

# Regularization parameter
set Model constant delta2 = 1.0, DOUBLE

# =================================================================================
# Set the output parameters
# =================================================================================
set Output condition = EQUAL_SPACING

set Number of outputs = 10

set Skip print steps = 1000
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ if(EXISTS "nucleation.cc")
endif()

# Set location of files
include_directories(${CMAKE_SOURCE_DIR}/../../../include)
include_directories(${CMAKE_SOURCE_DIR}/../../../src)
include_directories(${CMAKE_SOURCE_DIR}/../../include)
include_directories(${CMAKE_SOURCE_DIR}/../../src)
include_directories(${CMAKE_SOURCE_DIR})

# Set the location of the main.cc file
Expand All @@ -154,12 +154,12 @@ if(${PRISMS_PF_BUILD_DEBUG} STREQUAL "ON")
add_executable(main_debug ${TARGET_SRC})
set_property(TARGET main_debug PROPERTY OUTPUT_NAME main-debug)
deal_ii_setup_target(main_debug DEBUG)
target_link_libraries(main_debug ${CMAKE_SOURCE_DIR}/../../../libprisms-pf-debug.a)
target_link_libraries(main_debug ${CMAKE_SOURCE_DIR}/../../libprisms-pf-debug.a)
endif()

if(${PRISMS_PF_BUILD_RELEASE} STREQUAL "ON")
add_executable(main_release ${TARGET_SRC})
set_property(TARGET main_release PROPERTY OUTPUT_NAME main)
deal_ii_setup_target(main_release RELEASE)
target_link_libraries(main_release ${CMAKE_SOURCE_DIR}/../../../libprisms-pf-release.a)
target_link_libraries(main_release ${CMAKE_SOURCE_DIR}/../../libprisms-pf-release.a)
endif()
81 changes: 81 additions & 0 deletions automatic_tests/CHiMaD_benchmark6a/ICs_and_BCs.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// ===========================================================================
// FUNCTION FOR INITIAL CONDITIONS
// ===========================================================================

template <int dim, int degree>
void
customPDE<dim, degree>::setInitialCondition([[maybe_unused]] const Point<dim> &p,
[[maybe_unused]] const unsigned int index,
[[maybe_unused]] double &scalar_IC,
[[maybe_unused]] Vector<double> &vector_IC)
{
// ---------------------------------------------------------------------
// ENTER THE INITIAL CONDITIONS HERE
// ---------------------------------------------------------------------
// Enter the function describing conditions for the fields at point "p".
// Use "if" statements to set the initial condition for each variable
// according to its variable index

// The initial condition is a set of overlapping circles/spheres defined
// by a hyperbolic tangent function. The center of each circle/sphere is
// given by "center" and its radius is given by "radius".

if (index == 0)
{
double x = p[0];
double y = p[1];
double c0 = 0.5;
double c1 = 0.04;

double t1 = std::cos(0.2 * x) * std::cos(0.11 * y);
double t2 = std::cos(0.13 * x) * std::cos(0.087 * y) * std::cos(0.13 * x) *
std::cos(0.087 * y);
double t3 = std::cos(0.025 * x - 0.15 * y) * std::cos(0.07 * x - 0.02 * y);

scalar_IC = c0 + c1 * (t1 + t2 + t3);
}
else
{
scalar_IC = 0.0;
}

// =====================================================================
}

// ===========================================================================
// FUNCTION FOR NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS
// ===========================================================================

template <int dim, int degree>
void
customPDE<dim, degree>::setNonUniformDirichletBCs(
[[maybe_unused]] const Point<dim> &p,
[[maybe_unused]] const unsigned int index,
[[maybe_unused]] const unsigned int direction,
[[maybe_unused]] const double time,
[[maybe_unused]] double &scalar_BC,
[[maybe_unused]] Vector<double> &vector_BC)
{
// --------------------------------------------------------------------------
// ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE
// --------------------------------------------------------------------------
// Enter the function describing conditions for the fields at point "p".
// Use "if" statements to set the boundary condition for each variable
// according to its variable index. This function can be left blank if there
// are no non-uniform Dirichlet boundary conditions. For BCs that change in
// time, you can access the current time through the variable "time". The
// boundary index can be accessed via the variable "direction", which starts
// at zero and uses the same order as the BC specification in parameters.in
// (i.e. left = 0, right = 1, bottom = 2, top = 3, front = 4, back = 5).

if (index == 2)
{
if (direction == 1)
{
double y = p[1];
scalar_BC = std::sin(y / 7.0);
}
}

// -------------------------------------------------------------------------
}
98 changes: 98 additions & 0 deletions automatic_tests/CHiMaD_benchmark6a/customPDE.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#include <core/matrixFreePDE.h>

using namespace dealii;

template <int dim, int degree>
class customPDE : public MatrixFreePDE<dim, degree>
{
public:
// Constructor
customPDE(userInputParameters<dim> _userInputs)
: MatrixFreePDE<dim, degree>(_userInputs)
, userInputs(_userInputs) {};

// Function to set the initial conditions (in ICs_and_BCs.h)
void
setInitialCondition([[maybe_unused]] const Point<dim> &p,
[[maybe_unused]] const unsigned int index,
[[maybe_unused]] double &scalar_IC,
[[maybe_unused]] Vector<double> &vector_IC) override;

// Function to set the non-uniform Dirichlet boundary conditions (in
// ICs_and_BCs.h)
void
setNonUniformDirichletBCs([[maybe_unused]] const Point<dim> &p,
[[maybe_unused]] const unsigned int index,
[[maybe_unused]] const unsigned int direction,
[[maybe_unused]] const double time,
[[maybe_unused]] double &scalar_BC,
[[maybe_unused]] Vector<double> &vector_BC) override;

private:
#include <core/typeDefs.h>

const userInputParameters<dim> userInputs;

// Function to set the RHS of the governing equations for explicit time
// dependent equations (in equations.h)
void
explicitEquationRHS(
[[maybe_unused]] variableContainer<dim, degree, VectorizedArray<double>>
&variable_list,
[[maybe_unused]] const Point<dim, VectorizedArray<double>> q_point_loc,
[[maybe_unused]] const VectorizedArray<double> element_volume) const override;

// Function to set the RHS of the governing equations for all other equations
// (in equations.h)
void
nonExplicitEquationRHS(
[[maybe_unused]] variableContainer<dim, degree, VectorizedArray<double>>
&variable_list,
[[maybe_unused]] const Point<dim, VectorizedArray<double>> q_point_loc,
[[maybe_unused]] const VectorizedArray<double> element_volume) const override;

// Function to set the LHS of the governing equations (in equations.h)
void
equationLHS(
[[maybe_unused]] variableContainer<dim, degree, VectorizedArray<double>>
&variable_list,
[[maybe_unused]] const Point<dim, VectorizedArray<double>> q_point_loc,
[[maybe_unused]] const VectorizedArray<double> element_volume) const override;

// Function to set postprocessing expressions (in postprocess.h)
#ifdef POSTPROCESS_FILE_EXISTS
void
postProcessedFields(
[[maybe_unused]] const variableContainer<dim, degree, VectorizedArray<double>>
&variable_list,
[[maybe_unused]] variableContainer<dim, degree, VectorizedArray<double>>
&pp_variable_list,
[[maybe_unused]] const Point<dim, VectorizedArray<double>> q_point_loc,
[[maybe_unused]] const VectorizedArray<double> element_volume) const override;
#endif

// Function to set the nucleation probability (in nucleation.h)
#ifdef NUCLEATION_FILE_EXISTS
double
getNucleationProbability([[maybe_unused]] variableValueContainer variable_value,
[[maybe_unused]] double dV) const override;
#endif

// ================================================================
// Methods specific to this subclass
// ================================================================

// ================================================================
// Model constants specific to this subclass
// ================================================================

double McV = userInputs.get_model_constant_double("McV");
double KcV = userInputs.get_model_constant_double("KcV");
double rho = userInputs.get_model_constant_double("rho");
double c_alpha = userInputs.get_model_constant_double("c_alpha");
double c_beta = userInputs.get_model_constant_double("c_beta");
double k = userInputs.get_model_constant_double("k");
double epsilon = userInputs.get_model_constant_double("epsilon");

// ================================================================
};
Loading
Loading