-
Notifications
You must be signed in to change notification settings - Fork 0
Adapt Mesh
This page provides instructions for adaptive mesh refinement with respect to some functional (i.e. CL or CD). Before you start, you should have already created a simulation.
Adaptive mesh refinement is computationally intensive and should only be used whenever the answer needs to be more accurate. The approach is taken from Venditti et al.. It works the same for 2D airfoils and 3D vehicles alike. Here is an example for an Over-Wing Nacelle (OWN):
The package contains the following inputs:
- Simulation.sim -- the simulation you previously created here
- AdaptMesh.java -- a macro that tell STAR-CCM+ what to do
- SubmitJob.pbs -- an example PBS script if you wish to run the job on a cluster
It will create the following output:
- Simulation_Initial.sim -- the initial solution at grid refinement level 0
- Simulation_Final.sim -- the final solution at grid refinement level N
In the Java macro called AdaptMesh.java, fill out the user input section:
// ----------------------- USER INPUTS START HERE --------------------------
private void setUserInputs(){
isSave = true; // <-- optional (false = don't save simulation after it is run, true = save)
isWarmStart = true; // <-- optional (false = use sim file settings, true = use 1st order adjoint followed by 2nd order)
// - Solver -
numberPrimalSteps = 2000; // <-- required (number of iterations for which to run primal solver)
numberAdjointSteps = 2000; // <-- required (if isWarmStart = False)
number1stOrderGMRESAdjointSteps = 25; // <-- required (if isWarmStart = True)
number2ndOrderGMRESAdjointSteps = 25; // <-- required (if isWarmStart = True)
adapt.setPrimalCFL(10.0); // <-- required (CFL number to use for primal solver)
adapt.setAdjointCFL(50.0); // <-- required (set to high value if GMRES is being used; low otherwise)
// - Mesh Adaptation -
numberAdapationLevels = 3; // <-- required (number of adaptation levels desired; usually 2 - 4)
adapt.setAdaptMaxSizeChange(4.0); // <-- required (max allowed cell size change between 2 adaptation levels)
adapt.setAdaptTargetError(0.0005); // <-- required (cell won't be refined if error per cell is less than this)
// - Tell MeshAdaption object where to find these simulation objects -
adapt.setAdaptiveMeshCostFunctionName("CD"); // <-- required (adapt with respect to what? e.g. CL or CD)
adapt.setAdaptiveMeshCostFunctionReportName("CD"); // <-- required (name of report linked with adjoint cost fun)
adapt.setFluidRegionName("Fluid"); // <-- optional (only modify if you manually changed the sim file)
adapt.setMeshOperationNameName("Automated Mesh"); // <-- optional (only modify if you manually changed the sim file)
adapt.setMeshRefinementTableName("Mesh Refinement"); // <-- optional (name to use for the mesh refinement table)
}
// ----------------------- USER INPUTS END HERE ----------------------------
You can now run the macro locally on your desktop or remotely on a cluster, but first make sure you've properly followed the installation guidelines.
The working director {dir} should now contain the following files:
- AdaptMesh.java
- Simulation.sim
To run locally on your desktop, open a terminal and type the following at the command lines:
cd {dir}
starccm+ -cpubind -rsh ssh -podkey {pod} -licpath {lic} -power -np {np} -batch {macro} {sim}
where you should replace {...} with proper values. For example, on my local windows system:
{dir} = "C:\Users\SHB\Desktop\StarFoil_Examples\RAE2822(Adapt)"
{pod} = <my-podkey-number>
{lic} = 1999@flex.cd-adapco.com
{np} = 12
{macro} = AdaptMesh.java
{sim} = Airfoil.sim
The working directory {dir} should now contain the following files:
- AdaptMesh.java
- Simulation.sim
To run locally from the GUI:
- Open the simulation "Simulation.sim" from the GUI
- Play the macro "AdaptMesh.java" (press the "play" button in the GUI)
Note: These instructions assume you know how to use a cluster. If not, this guide might help.
On the remote cluster, the working directory {dir} should contain the following files:
- Simulation.sim
- AdaptMesh.java
- SubmitJob.pbs
- ASO_jar
- SubmitJob.pbs
To submit a job, just type the following from the command line:
qsub SubmitJob.pbs
The contents of the PBS file should be modified accordingly, but here is an example:
#!/bin/bash
# ----------------QSUB Parameters----------------- #
#PBS -N Enter-Job-Name-Here
#PBS -l nodes=1:ppn=24
#PBS -l pmem=8gb
#PBS -l walltime=24:00:00
#PBS -q Enter-Queue-Name-Here
#PBS -j oe
#PBS -o Job.out
# ----------------Load Modules-------------------- #
cd $PBS_O_WORKDIR
module load starccmplus/12.02.010
module load impi/5.0.1.035
module load anaconda3/4.2.0
# ----------------Print Some Info-------------------- #
echo Running on host `hostname`
echo Time is `date`
echo Directory is `pwd`
echo This jobs runs on the following processors:
NODES=`cat $PBS_NODEFILE`
echo $NODES
# Compute the number of processors
NPROCS=`wc -l < $PBS_NODEFILE`
echo This job has allocated $NPROCS nodes
# ---------------Execute Script ------------------ #
starccm+ -podkey <enter-podkey-here> -licpath 1999@flex.cd-adapco.com -mpi intel -power -np $NPROCS -classpath $PBS_O_WORKDIR/ASO_jar -machinefile $PBS_NODEFILE -batch $PBS_O_WORKDIR/AdaptMesh.java Simulation.sim > starccm.out
# ----------------Print end time-------------------- #
echo Done... Time is `date`
#####
# To run interactively, modify the following example command:
# qsub -I -X -q asdl -l nodes=1:ppn=24,walltime=2:00:00,pmem=8gb