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

changed suffix in AM application to prm #195

Open
wants to merge 1 commit into
base: additive_manufacturing
Choose a base branch
from
Open
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
81 changes: 81 additions & 0 deletions applications/_additive_manufacturing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
##
# CMake script for the PRISMS-PF applications:
##

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)

# Find deal.II installation
FIND_PACKAGE(deal.II 8.3.0 REQUIRED
HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR})

# Check to make sure deal.II is configured with p4est
IF(NOT ${DEAL_II_WITH_P4EST})
MESSAGE(FATAL_ERROR "\n"
"*** deal.II was not installed with p4est. ***\n\n"
“The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n”
“user guide to confirm that deal.II and p4est were installed and configured correctly.”
)
ENDIF()

DEAL_II_INITIALIZE_CACHED_VARIABLES()

# Set up the debug, release, and run targets
ADD_CUSTOM_TARGET(debug
COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR}
COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all
COMMENT "Switch CMAKE_BUILD_TYPE to Debug"
)

ADD_CUSTOM_TARGET(release
COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR}
COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all
COMMENT "Switch CMAKE_BUILD_TYPE to Release"
)

ADD_CUSTOM_TARGET(run COMMAND main
COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration"
)

PROJECT(myapp)
if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease)
SET(CMAKE_BUILD_TYPE Debug)
endif()

# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables
if (EXISTS "postprocess.cc")
add_definitions(-DPOSTPROCESS_FILE_EXISTS)
endif()
if (EXISTS "nucleation.cc")
add_definitions(-DNUCLEATION_FILE_EXISTS)
endif()

# Append extra flags for the GNU compiler to suppress some warnings
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra")
set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra")
#set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable")
#set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable")
endif()

ADD_EXECUTABLE(main main.cc )

DEAL_II_SETUP_TARGET(main)

set(cmd "cmake")
set(arg "CMakeLists.txt")
set(dir ${PROJECT_SOURCE_DIR}/../..)
EXECUTE_PROCESS(COMMAND ${cmd} ${arg}
WORKING_DIRECTORY ${dir})

set(cmd "make")

EXECUTE_PROCESS(COMMAND ${cmd}
WORKING_DIRECTORY ${dir})

if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a)
elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease")
TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a)
else()
TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a)
endif()
277 changes: 277 additions & 0 deletions applications/_additive_manufacturing/ICs_and_BCs.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
// ===========================================================================
// FUNCTION FOR INITIAL CONDITIONS
// ===========================================================================

template <int dim, int degree>
void customPDE<dim,degree>::setInitialCondition(const dealii::Point<dim> &p, const unsigned int index, double & scalar_IC, dealii::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".


std::vector<dealii::Point<dim>> center;

// The big grains
// {dealii::Point<dim> p(0.2, 0.15); center.push_back(p);}
// {dealii::Point<dim> p(0.25, 0.7); center.push_back(p);}
// {dealii::Point<dim> p(0.5, 0.5); center.push_back(p);}
// {dealii::Point<dim> p(0.6, 0.85); center.push_back(p);}
// {dealii::Point<dim> p(0.85, 0.35); center.push_back(p);}

// {dealii::Point<dim> p(0.08, 0.92); center.push_back(p);}
// {dealii::Point<dim> p(0.75, 0.6); center.push_back(p);}
// {dealii::Point<dim> p(0.75, 0.1); center.push_back(p);}
// {dealii::Point<dim> p(0.2, 0.45); center.push_back(p);}

{dealii::Point<dim> p(0.0, 0.15); center.push_back(p);}
{dealii::Point<dim> p(0.0, 0.7); center.push_back(p);}
{dealii::Point<dim> p(0.0, 0.5); center.push_back(p);}
{dealii::Point<dim> p(0.0, 0.85); center.push_back(p);}
{dealii::Point<dim> p(0.0, 0.35); center.push_back(p);}

{dealii::Point<dim> p(0.0, 0.92); center.push_back(p);}
{dealii::Point<dim> p(0.0, 0.6); center.push_back(p);}
{dealii::Point<dim> p(0.0, 0.1); center.push_back(p);}
{dealii::Point<dim> p(0.0, 0.45); center.push_back(p);}

double init_factor = 1.0e6;


std::vector<double> rad = {0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.01, 0.05, 0.05, 0.05, 0.05, 0.05};


double dist = 0.0;
scalar_IC = 0;
if (index==0){
for (unsigned int dir = 0; dir < dim; dir++){
dist += (p[dir]-center[0][dir]*userInputs.domain_size[dir])*(p[dir]-center[0][dir]*userInputs.domain_size[dir]);
}
dist = std::sqrt(dist);

scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[0]*userInputs.domain_size[0])/0.5));
}
dist=0.0;
if (index==1){
for (unsigned int dir = 0; dir < dim; dir++){
dist += (p[dir]-center[1][dir]*userInputs.domain_size[dir])*(p[dir]-center[1][dir]*userInputs.domain_size[dir]);
}
dist = std::sqrt(dist);

scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[1]*userInputs.domain_size[0])/0.5));
}

dist=0.0;
if (index==2){
for (unsigned int dir = 0; dir < dim; dir++){
dist += (p[dir]-center[2][dir]*userInputs.domain_size[dir])*(p[dir]-center[2][dir]*userInputs.domain_size[dir]);
}
dist = std::sqrt(dist);

scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[2]*userInputs.domain_size[0])/0.5));
}

dist=0.0;
if (index==3){
for (unsigned int dir = 0; dir < dim; dir++){
dist += (p[dir]-center[3][dir]*userInputs.domain_size[dir])*(p[dir]-center[3][dir]*userInputs.domain_size[dir]);
}
dist = std::sqrt(dist);

scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[3]*userInputs.domain_size[0])/0.5));
}

dist=0.0;
if (index==4){
for (unsigned int dir = 0; dir < dim; dir++){
dist += (p[dir]-center[4][dir]*userInputs.domain_size[dir])*(p[dir]-center[4][dir]*userInputs.domain_size[dir]);
}
dist = std::sqrt(dist);

scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[4]*userInputs.domain_size[0])/0.5));
}
dist=0.0;
if (index==5){
for (unsigned int dir = 0; dir < dim; dir++){
dist += (p[dir]-center[5][dir]*userInputs.domain_size[dir])*(p[dir]-center[5][dir]*userInputs.domain_size[dir]);
}
dist = std::sqrt(dist);

scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[5]*userInputs.domain_size[0])/0.5));
}
dist=0.0;
if (index==0){
for (unsigned int dir = 0; dir < dim; dir++){
dist += (p[dir]-center[6][dir]*userInputs.domain_size[dir])*(p[dir]-center[6][dir]*userInputs.domain_size[dir]);
}
dist = std::sqrt(dist);

scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[6]*userInputs.domain_size[0])/0.5));
}

dist=0.0;
if (index==0){
for (unsigned int dir = 0; dir < dim; dir++){
dist += (p[dir]-center[7][dir]*userInputs.domain_size[dir])*(p[dir]-center[7][dir]*userInputs.domain_size[dir]);
}
dist = std::sqrt(dist);

scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[7]*userInputs.domain_size[0])/0.5));
}

// dist=0.0;
// if (index==0){
// for (unsigned int dir = 0; dir < dim; dir++){
// dist += (p[dir]-center[8][dir]*userInputs.domain_size[dir])*(p[dir]-center[8][dir]*userInputs.domain_size[dir]);
// }
// dist = std::sqrt(dist);

// scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[8]*userInputs.domain_size[0])/0.5));
// }









dist=0.0;
if (index==6){
for (unsigned int dir = 0; dir < dim; dir++){
dist += (p[dir]-center[0][dir]*userInputs.domain_size[dir])*(p[dir]-center[0][dir]*userInputs.domain_size[dir]);
}
dist = std::sqrt(dist);

scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[0]*userInputs.domain_size[0])/0.5));
}

dist=0.0;
if (index==6){
for (unsigned int dir = 0; dir < dim; dir++){
dist += (p[dir]-center[1][dir]*userInputs.domain_size[dir])*(p[dir]-center[1][dir]*userInputs.domain_size[dir]);
}
dist = std::sqrt(dist);

scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[1]*userInputs.domain_size[0])/0.5));
}

dist=0.0;
if (index==6){
for (unsigned int dir = 0; dir < dim; dir++){
dist += (p[dir]-center[2][dir]*userInputs.domain_size[dir])*(p[dir]-center[2][dir]*userInputs.domain_size[dir]);
}
dist = std::sqrt(dist);

scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[2]*userInputs.domain_size[0])/0.5));
}

dist=0.0;
if (index==6){
for (unsigned int dir = 0; dir < dim; dir++){
dist += (p[dir]-center[3][dir]*userInputs.domain_size[dir])*(p[dir]-center[3][dir]*userInputs.domain_size[dir]);
}
dist = std::sqrt(dist);

scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[3]*userInputs.domain_size[0])/0.5));
}

dist=0.0;
if (index==6){
for (unsigned int dir = 0; dir < dim; dir++){
dist += (p[dir]-center[4][dir]*userInputs.domain_size[dir])*(p[dir]-center[4][dir]*userInputs.domain_size[dir]);
}
dist = std::sqrt(dist);

scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[4]*userInputs.domain_size[0])/0.5));
}

dist=0.0;
if (index==6){
for (unsigned int dir = 0; dir < dim; dir++){
dist += (p[dir]-center[5][dir]*userInputs.domain_size[dir])*(p[dir]-center[5][dir]*userInputs.domain_size[dir]);
}
dist = std::sqrt(dist);

scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[5]*userInputs.domain_size[0])/0.5));
}

dist=0.0;
if (index==6){
for (unsigned int dir = 0; dir < dim; dir++){
dist += (p[dir]-center[6][dir]*userInputs.domain_size[dir])*(p[dir]-center[6][dir]*userInputs.domain_size[dir]);
}
dist = std::sqrt(dist);

scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[6]*userInputs.domain_size[0])/0.5));
}

dist=0.0;
if (index==6){
for (unsigned int dir = 0; dir < dim; dir++){
dist += (p[dir]-center[7][dir]*userInputs.domain_size[dir])*(p[dir]-center[7][dir]*userInputs.domain_size[dir]);
}
dist = std::sqrt(dist);

scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[7]*userInputs.domain_size[0])/0.5));
}

// dist=0.0;
// if (index==6){
// for (unsigned int dir = 0; dir < dim; dir++){
// dist += (p[dir]-center[8][dir]*userInputs.domain_size[dir])*(p[dir]-center[8][dir]*userInputs.domain_size[dir]);
// }
// dist = std::sqrt(dist);

// scalar_IC += 0.5*(1.0-std::tanh(init_factor*(dist-rad[8]*userInputs.domain_size[0])/0.5));
// }


// --------------------------------------------------------------------------



if (index==7){
if(p[0]<userInputs.domain_size[0]*0.05){
scalar_IC=1720.0;
}
else{

scalar_IC=1724.0;

}
}


}

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

template <int dim, int degree>
void customPDE<dim,degree>::setNonUniformDirichletBCs(const dealii::Point<dim> &p, const unsigned int index, const unsigned int direction, const double time, double & scalar_BC, dealii::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).


// -------------------------------------------------------------------------

}
Loading