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

Add tutorial flow-over-plate Code_Aster-OpenFOAM #74

Merged
merged 9 commits into from
Mar 27, 2020
47 changes: 47 additions & 0 deletions CHT/flow-over-plate/buoyantSimpleFoam-aster/Allclean
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

echo "Cleaning..."

. $WM_PROJECT_DIR/bin/tools/CleanFunctions

# Participant 1: Solid
Participant1="Solid"
rm -fv ${Participant1}/solid.mess
rm -fv ${Participant1}/solid.resu
rm -fv ${Participant1}/solid.rmed
rm -fv ${Participant1}.log
rm -fvr ${Participant1}/REPE_OUT
mkdir ${Participant1}/REPE_OUT

# Participant 2: Fluid
Participant2="Fluid"
rm -fv ${Participant2}.log
cd ${Participant2}
cleanCase
touch Fluid.foam
# Remove the log files
rm -fv ${Participant2}_blockMesh.log
rm -fv ${Participant2}_checkMesh.log
rm -fv ${Participant2}_decomposePar.log
rm -fv ${Participant2}_reconstructPar.log
cd ..


# Remove the preCICE-related log files
echo "Deleting the preCICE log files..."
rm -fv \
precice-*.log \
precice-*-events.json

# Output files for preCICE versions before 1.2:
rm -fv \
iterations-${Participant1}.txt iterations-${Participant2}.txt \
convergence-${Participant1}.txt convergence-${Participant2}.txt \
Events-${Participant1}.log Events-${Participant2}.log \
EventTimings-${Participant1}.log EventTimings-${Participant2}.log

# Remove the preCICE address files
rm -rfv precice-run
rm -fv .*.address

echo "Cleaning complete!"
96 changes: 96 additions & 0 deletions CHT/flow-over-plate/buoyantSimpleFoam-aster/Allrun
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/bash

cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions

# This script prepares and runs all the participants in one terminal,
# forwarding the solvers' output to log files.
# Alternatively, you may execute the scripts "runSolid" and "runFluid"
# in separate terminals.

# Run this script with "-parallel" for parallel simulations

# The script "Allclean" cleans-up the result and log files.
# Set up the run parameters:

# 1 for true, 0 for false
parallel=0
if [ "$1" = "-parallel" ]; then
parallel=1
fi

# =============== Participant 1: Fluid ===========================
Participant1="Fluid"

# Prepare
echo "Preparing the ${Participant1} participant..."

cd $Participant1
blockMesh > ${Participant1}_blockMesh.log 2>&1
cd ..

# Run and get the process id
if [ $parallel -eq 1 ]; then
echo " Decomposing the case..."
decomposePar -force -case ${Participant1} > ${Participant1}_decomposePar.log 2>&1
cd ${Participant1}
nproc=$(getNumberOfProcessors)
cd ..
echo " Starting the ${Participant1} participant in parallel..."
mpirun -np ${nproc} buoyantSimpleFoam -parallel -case ${Participant1} > ${Participant1}.log 2>&1 &
else
echo " Starting the ${Participant1} participant in serial..."
buoyantSimpleFoam -case ${Participant1} > ${Participant1}.log 2>&1 &
fi
PIDParticipant1=$!

# =============== Participant 2: Solid ===========================
Participant2="Solid"
export PRECICE_PARTICIPANT=${Participant2}
export TUTORIAL_ROOT=${PWD}

# Run
echo " Starting the ${Participant2} participant..."
as_run --run ${Participant2}/solid.export > ${Participant2}.log 2>&1 &
PIDParticipant2=$!


# =============== Wait for all the participants to finish =======
echo "Waiting for the participants to exit..., PIDs: ${PIDParticipant1}, ${PIDParticipant2}"
echo "(you may run 'tail -f ${Participant1}.log' in another terminal to check the progress)"

echo "To interrupt the simulation, press 'c'. Ctrl+C will only send the processes to the background."
while [ -e /proc/${PIDParticipant1} ]; do
read -r -t1 -n1 input
if [ "$input" = "c" ]; then
kill ${PIDParticipant1}
kill ${PIDParticipant2}
false
fi
done

if [ $? -ne 0 ] || [ "$(grep -c -E "error:" ${Participant1}.log)" -ne 0 ] || [ "$(grep -c -E "error:" ${Participant2}.log)" -ne 0 ]; then
echo ""
echo "Something went wrong... See the log files for more."
# Precaution
kill ${PIDParticipant1}
kill ${PIDParticipant2}
else
echo ""
echo "The simulation completed! (check for any errors)"
if [ $parallel -eq 1 ]; then
echo "Reconstructing fields..."
reconstructPar -case ${Participant1} > ${Participant1}_reconstructPar.log 2>&1 &
fi

# Workaround for issue #26
echo "Problems with time directories without results? Run the script removeObsoleteFolders.sh and see issue #26 on GitHub."
# ./removeObsoleteFolders.sh

echo "You may now open '${Participant1}/${Participant1}.foam' in ParaView."
# Note: ".foam" triggers the native OpenFOAM reader of ParaView.
# Change to ".OpenFOAM" to use the OpenFOAM reader provided with OpenFOAM.
fi

echo ""
echo "### NOTE ### Make sure to use the correct solver for your OpenFOAM version! (pimpleFoam for OpenFOAM v1806, OpenFOAM 6, or newer, vs pimpleDyMFoam for older) You may change this in your Fluid/system/controlDict file, if needed."
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./Allrun -parallel
68 changes: 68 additions & 0 deletions CHT/flow-over-plate/buoyantSimpleFoam-aster/Fluid/0/T
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object T;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 0 0 1 0 0 0];

internalField uniform 300;

boundaryField
{

inlet
{
type fixedValue;
value uniform 300;
}

outlet
{
type zeroGradient;
value uniform 300;
}

interface
{
type mixed;
refGradient uniform 0;
refValue uniform 310;
valueFraction uniform 0.5;
}

top
{
type zeroGradient;
value uniform 300;
}

bottom
{
type zeroGradient;
value uniform 300;
}

slip-bottom
{
type zeroGradient;
value uniform 300;
}

outerWall
{
type zeroGradient;
value uniform 300;
}

defaultFaces
{
type empty;
}

}

// ************************************************************************* //
57 changes: 57 additions & 0 deletions CHT/flow-over-plate/buoyantSimpleFoam-aster/Fluid/0/U
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 1 -1 0 0 0 0];

internalField uniform (.1 0 0);

boundaryField
{
inlet
{
type fixedValue;
value uniform (.1 0 0);
}

outlet
{
type zeroGradient;
}

top
{
type slip;
value uniform (.1 0 0);
}

bottom
{
type fixedValue;
value uniform (0 0 0);
}

slip-bottom
{
type slip;
}

interface
{
type fixedValue;
value uniform (0 0 0);
}

defaultFaces
{
type empty;
}

}

// ************************************************************************* //
55 changes: 55 additions & 0 deletions CHT/flow-over-plate/buoyantSimpleFoam-aster/Fluid/0/alphat
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object alphat;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [1 -1 -1 0 0 0 0];

internalField uniform 0;

boundaryField
{
inlet
{
type fixedValue;
value uniform 0;
}
outlet
{
type fixedValue;
value uniform 0;
}
top
{
type fixedValue;
value uniform 0;
}
bottom
{
type fixedValue;
value uniform 0;
}
slip-bottom
{
type fixedValue;
value uniform 0;
}
interface
{
type fixedValue;
value uniform 0;
}
defaultFaces
{
type empty;
}

}


// ************************************************************************* //
54 changes: 54 additions & 0 deletions CHT/flow-over-plate/buoyantSimpleFoam-aster/Fluid/0/epsilon
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 2 -3 0 0 0 0];

internalField uniform 1e-6;

boundaryField
{
inlet
{
type fixedValue;
value uniform 1e-6;
}
outlet
{
type fixedValue;
value uniform 1e-6;
}
top
{
type fixedValue;
value uniform 1e-6;
}
bottom
{
type fixedValue;
value uniform 1e-6;
}
slip-bottom
{
type fixedValue;
value uniform 1e-6;
}
interface
{
type fixedValue;
value uniform 1e-6;
}
defaultFaces
{
type empty;
}
}


// ************************************************************************* //
Loading