Commit a101415f authored by Richard Angersbach's avatar Richard Angersbach
Browse files

Split visualization.ir folder into interactive/postprocessing

parent 961a239e
......@@ -52,9 +52,9 @@ import exastencils.stencil.ir._
import exastencils.timing.ir._
import exastencils.util._
import exastencils.util.ir._
import exastencils.visualization.ir.IR_ResolveVisualizationPrinters
import exastencils.visualization.ir.cimg.IR_ResolveCImgFunctions
import exastencils.visualization.ir.visit.IR_SetupVisit
import exastencils.visualization.ir.interactive.cimg.IR_ResolveCImgFunctions
import exastencils.visualization.ir.interactive.visit.IR_SetupVisit
import exastencils.visualization.ir.postprocessing.IR_ResolveVisualizationPrinters
/// IR_LayerHandler
......
......@@ -7,7 +7,7 @@ import exastencils.base.ir.IR_ImplicitConversion._
import exastencils.field.ir.IR_IV_ActiveSlot
import exastencils.io.ir.IR_DataBuffer
import exastencils.io.ir.IR_IV_FragmentInfo
import exastencils.visualization.ir.netCDF.IR_PrintExodus
import exastencils.visualization.ir.postprocessing.netCDF.IR_PrintExodus
/// IR_PrintExodusNNF
......
......@@ -7,7 +7,7 @@ import exastencils.base.ir.IR_ImplicitConversion._
import exastencils.field.ir.IR_IV_ActiveSlot
import exastencils.io.ir.IR_DataBuffer
import exastencils.io.ir.IR_IV_FragmentInfo
import exastencils.visualization.ir.netCDF.IR_PrintExodus
import exastencils.visualization.ir.postprocessing.netCDF.IR_PrintExodus
/// IR_PrintExodusNS
// 2D or 3D
......
......@@ -10,7 +10,7 @@ import exastencils.domain.ir.IR_IV_IsValidForDomain
import exastencils.field.ir._
import exastencils.grid.ir.IR_AtCellCenter
import exastencils.io.ir.IR_IV_TemporaryBuffer
import exastencils.visualization.ir.IR_PrintVisualizationQuads
import exastencils.visualization.ir.postprocessing.IR_PrintVisualizationQuads
trait IR_PrintVisualizationNS extends IR_PrintVisualizationQuads {
def numDimsGrid : Int = p.numDimsGrid
......
......@@ -25,7 +25,7 @@ import exastencils.base.ir._
import exastencils.core.Duplicate
import exastencils.parallelization.api.mpi._
import exastencils.util.ir.IR_Print
import exastencils.visualization.ir.vtk.IR_PrintVtkQuads
import exastencils.visualization.ir.postprocessing.vtk.IR_PrintVtkQuads
/// IR_PrintVtkNNF
......
......@@ -25,7 +25,7 @@ import exastencils.base.ir._
import exastencils.core.Duplicate
import exastencils.parallelization.api.mpi._
import exastencils.util.ir.IR_Print
import exastencils.visualization.ir.vtk.IR_PrintVtkQuads
import exastencils.visualization.ir.postprocessing.vtk.IR_PrintVtkQuads
/// IR_PrintVtkNS
......
......@@ -12,7 +12,7 @@ import exastencils.grid.ir.IR_AtNode
import exastencils.io.ir.IR_DataBuffer
import exastencils.io.ir.IR_IV_FragmentInfo
import exastencils.util.ir.IR_Print
import exastencils.visualization.ir.xdmf.IR_PrintXdmf
import exastencils.visualization.ir.postprocessing.xdmf.IR_PrintXdmf
/// IR_PrintXdmfNNF
// 2D or 3D
......
......@@ -11,7 +11,7 @@ import exastencils.field.ir.IR_IV_ActiveSlot
import exastencils.grid.ir.IR_AtNode
import exastencils.io.ir._
import exastencils.util.ir.IR_Print
import exastencils.visualization.ir.xdmf.IR_PrintXdmf
import exastencils.visualization.ir.postprocessing.xdmf.IR_PrintXdmf
/// IR_PrintXdmfNS
// 2D or 3D
......
......@@ -10,7 +10,7 @@ import exastencils.field.ir.IR_IV_ActiveSlot
import exastencils.io.ir.IR_DataBuffer
import exastencils.io.ir.IR_IV_FragmentInfo
import exastencils.logger.Logger
import exastencils.visualization.ir.netCDF.IR_PrintExodus
import exastencils.visualization.ir.postprocessing.netCDF.IR_PrintExodus
/// IR_PrintExodusSWE
// 2D only
......
......@@ -15,7 +15,7 @@ import exastencils.grid.ir.IR_VF_NodePositionAsVec
import exastencils.io.ir._
import exastencils.logger.Logger
import exastencils.util.ir.IR_Print
import exastencils.visualization.ir.IR_PrintVisualizationTriangles
import exastencils.visualization.ir.postprocessing.IR_PrintVisualizationTriangles
trait IR_PrintVisualizationSWE extends IR_PrintVisualizationTriangles {
def numDimsGrid = 2
......
......@@ -26,7 +26,7 @@ import exastencils.core.Duplicate
import exastencils.field.ir.IR_Field
import exastencils.parallelization.api.mpi._
import exastencils.util.ir.IR_Print
import exastencils.visualization.ir.vtk.IR_PrintVtkTriangles
import exastencils.visualization.ir.postprocessing.vtk.IR_PrintVtkTriangles
/// IR_PrintVtkSWE
......
......@@ -14,7 +14,7 @@ import exastencils.grid.ir.IR_AtNode
import exastencils.io.ir._
import exastencils.logger.Logger
import exastencils.util.ir.IR_Print
import exastencils.visualization.ir.xdmf.IR_PrintXdmf
import exastencils.visualization.ir.postprocessing.xdmf.IR_PrintXdmf
/// IR_PrintXdmfSWE
// 2D only
......
......@@ -7,7 +7,7 @@ import exastencils.config.Knowledge
import exastencils.core.Duplicate
import exastencils.io.ir._
import exastencils.logger.Logger
import exastencils.visualization.ir.IR_ResolveVisualizationPrinters
import exastencils.visualization.ir.postprocessing.IR_ResolveVisualizationPrinters
/// IR_FieldIO
......
......@@ -29,8 +29,8 @@ import exastencils.grid.ir._
import exastencils.logger.Logger
import exastencils.parallelization.api.mpi._
import exastencils.util.ir.IR_Print
import exastencils.visualization.ir.netCDF.IR_PrintNetCDF
import exastencils.visualization.ir.xdmf._
import exastencils.visualization.ir.postprocessing.netCDF.IR_PrintNetCDF
import exastencils.visualization.ir.postprocessing.xdmf._
/// IR_PrintField
......
package exastencils.visualization.ir.visit
import exastencils.base.ir.IR_VariableDeclaration
import exastencils.baseExt.ir._
import exastencils.config._
import exastencils.datastructures._
import exastencils.field.ir.IR_FieldCollection
import exastencils.globals.ir.IR_GlobalCollection
import exastencils.grid.ir._
import exastencils.logger.Logger
import exastencils.visualization.ir.visit.IR_VisItGlobals._
object IR_SetupVisit extends DefaultStrategy("Setup Visit functions") {
/* TODO:
* Utilize virtual fields for node/cell positions
* too many copies -> read docs for ghost layer mechanism from VisIt
* assumes rectangular domains -> generally blockstructured grids not supported
* Higher-order datatypes unsupported
*/
import IR_VisItUtil._
override def apply(applyAtNode : Option[Node]) : Unit = {
// check if innerPoints were set manually in layout
for (field <- IR_FieldCollection.objects) {
for (d <- 0 until field.numDimsGrid) {
val numDupOrInner = field.layout.defIdxDupRightEnd(d) - field.layout.defIdxDupLeftBegin(d)
field.layout.localization match {
case IR_AtNode | IR_AtFaceCenter(`d`) =>
if (numDupOrInner != Knowledge.domain_fragmentLengthAsVec(d) * (1 << field.level) + 1)
Logger.error("VisIt interface currently only supports fields bound to a mesh with \"fragmentLength(d) * 2^level +1\" grid nodes.")
case IR_AtCellCenter | IR_AtFaceCenter(_) =>
if (numDupOrInner != Knowledge.domain_fragmentLengthAsVec(d) * (1 << field.level) + 0)
Logger.error("VisIt interface currently only supports fields bound to a mesh with \"fragmentLength(d) * 2^level +0\" cells.")
}
}
}
super.apply(applyAtNode)
}
this += Transformation("Add dependencies, new user functions and globals", {
case fctCollection : IR_UserFunctions =>
if (Knowledge.dimensionality > 1)
fctCollection += IR_VisItSimGetVariable()
fctCollection += IR_VisItSimGetMesh()
fctCollection += IR_VisItSimGetMetaData()
fctCollection += IR_VisItControlCommandCallback()
fctCollection += IR_VisItInitialization()
fctCollection += IR_VisItDestroy()
fctCollection += IR_VisItMainloop()
if (Knowledge.mpi_enabled) {
fctCollection += IR_VisItProcessVisItCommand()
fctCollection += IR_VisItSimGetDomainList()
fctCollection += IR_VisItBroadcastIntCallback()
fctCollection += IR_VisItBroadcastStringCallback()
fctCollection += IR_VisItSlaveProcessCallback()
}
Settings.pathsInc = (Settings.pathsInc :+ "$(SIMV2DIR)/include").distinct
Settings.pathsLib = (Settings.pathsLib :+ "$(SIMV2DIR)/lib").distinct
Settings.additionalLibs += "simV2"
Settings.additionalLibs += "dl"
fctCollection.externalDependencies += "string.h"
fctCollection.externalDependencies += "stdlib.h"
if (Knowledge.dimensionality == 1 || Knowledge.dimensionality == 2) fctCollection.externalDependencies += "stdexcept"
if (Knowledge.mpi_enabled) {
fctCollection.externalDependencies += "stdio.h"
}
fctCollection.externalDependencies += "VisItControlInterface_V2.h"
fctCollection.externalDependencies += "VisItDataInterface_V2.h"
if (Platform.targetCompiler == "MSVC") {
fctCollection.externalDependencies += "direct.h"
} else {
fctCollection.externalDependencies += "unistd.h"
}
fctCollection
case globalCollection : IR_GlobalCollection =>
globalCollection.variables += curLevelDecl
globalCollection.variables += curSlotDecl
globalCollection.variables += runModeDecl
globalCollection.variables += updatePlotsDecl
if (Knowledge.dimensionality == 1 || Knowledge.dimensionality == 2) globalCollection.variables += scaleCurvemeshDecl
// coordinate arrays for 2 and 3 dim. rectilinear meshes
if (Knowledge.dimensionality > 1) {
for (coords <- coordsArrays.distinct) globalCollection.variables += IR_VariableDeclaration(coords)
}
// coordinate arrays for 2 and 3 dim. curvilinear meshes (partially consisting of 1d or 2d variables)
if (Knowledge.dimensionality < 3) {
for (curveCoords <- curveCoordsArrays.distinct) globalCollection.variables += IR_VariableDeclaration(curveCoords)
}
globalCollection.variables += commandNamesDecl
globalCollection
})
}
package exastencils.visualization.ir.interactive.visit
import exastencils.base.ir.IR_VariableDeclaration
import exastencils.baseExt.ir._
import exastencils.config._
import exastencils.datastructures._
import exastencils.field.ir.IR_FieldCollection
import exastencils.globals.ir.IR_GlobalCollection
import exastencils.grid.ir._
import exastencils.logger.Logger
import exastencils.visualization.ir.interactive.visit.IR_VisItGlobals._
object IR_SetupVisit extends DefaultStrategy("Setup Visit functions") {
/* TODO:
* Utilize virtual fields for node/cell positions
* too many copies -> read docs for ghost layer mechanism from VisIt
* assumes rectangular domains -> generally blockstructured grids not supported
* Higher-order datatypes unsupported
*/
import IR_VisItUtil._
override def apply(applyAtNode : Option[Node]) : Unit = {
// check if innerPoints were set manually in layout
for (field <- IR_FieldCollection.objects) {
for (d <- 0 until field.numDimsGrid) {
val numDupOrInner = field.layout.defIdxDupRightEnd(d) - field.layout.defIdxDupLeftBegin(d)
field.layout.localization match {
case IR_AtNode | IR_AtFaceCenter(`d`) =>
if (numDupOrInner != Knowledge.domain_fragmentLengthAsVec(d) * (1 << field.level) + 1)
Logger.error("VisIt interface currently only supports fields bound to a mesh with \"fragmentLength(d) * 2^level +1\" grid nodes.")
case IR_AtCellCenter | IR_AtFaceCenter(_) =>
if (numDupOrInner != Knowledge.domain_fragmentLengthAsVec(d) * (1 << field.level) + 0)
Logger.error("VisIt interface currently only supports fields bound to a mesh with \"fragmentLength(d) * 2^level +0\" cells.")
}
}
}
super.apply(applyAtNode)
}
this += Transformation("Add dependencies, new user functions and globals", {
case fctCollection : IR_UserFunctions =>
if (Knowledge.dimensionality > 1)
fctCollection += IR_VisItSimGetVariable()
fctCollection += IR_VisItSimGetMesh()
fctCollection += IR_VisItSimGetMetaData()
fctCollection += IR_VisItControlCommandCallback()
fctCollection += IR_VisItInitialization()
fctCollection += IR_VisItDestroy()
fctCollection += IR_VisItMainloop()
if (Knowledge.mpi_enabled) {
fctCollection += IR_VisItProcessVisItCommand()
fctCollection += IR_VisItSimGetDomainList()
fctCollection += IR_VisItBroadcastIntCallback()
fctCollection += IR_VisItBroadcastStringCallback()
fctCollection += IR_VisItSlaveProcessCallback()
}
Settings.pathsInc = (Settings.pathsInc :+ "$(SIMV2DIR)/include").distinct
Settings.pathsLib = (Settings.pathsLib :+ "$(SIMV2DIR)/lib").distinct
Settings.additionalLibs += "simV2"
Settings.additionalLibs += "dl"
fctCollection.externalDependencies += "string.h"
fctCollection.externalDependencies += "stdlib.h"
if (Knowledge.dimensionality == 1 || Knowledge.dimensionality == 2) fctCollection.externalDependencies += "stdexcept"
if (Knowledge.mpi_enabled) {
fctCollection.externalDependencies += "stdio.h"
}
fctCollection.externalDependencies += "VisItControlInterface_V2.h"
fctCollection.externalDependencies += "VisItDataInterface_V2.h"
if (Platform.targetCompiler == "MSVC") {
fctCollection.externalDependencies += "direct.h"
} else {
fctCollection.externalDependencies += "unistd.h"
}
fctCollection
case globalCollection : IR_GlobalCollection =>
globalCollection.variables += curLevelDecl
globalCollection.variables += curSlotDecl
globalCollection.variables += runModeDecl
globalCollection.variables += updatePlotsDecl
if (Knowledge.dimensionality == 1 || Knowledge.dimensionality == 2) globalCollection.variables += scaleCurvemeshDecl
// coordinate arrays for 2 and 3 dim. rectilinear meshes
if (Knowledge.dimensionality > 1) {
for (coords <- coordsArrays.distinct) globalCollection.variables += IR_VariableDeclaration(coords)
}
// coordinate arrays for 2 and 3 dim. curvilinear meshes (partially consisting of 1d or 2d variables)
if (Knowledge.dimensionality < 3) {
for (curveCoords <- curveCoordsArrays.distinct) globalCollection.variables += IR_VariableDeclaration(curveCoords)
}
globalCollection.variables += commandNamesDecl
globalCollection
})
}
package exastencils.visualization.ir.visit
import scala.collection.mutable.ListBuffer
import exastencils.base.ir._
import exastencils.base.ir.IR_ImplicitConversion._
import exastencils.config.Knowledge
import exastencils.datastructures.Transformation.OutputType
import exastencils.field.ir.IR_FieldCollection
import exastencils.visualization.ir.visit.IR_VisItGlobals._
import exastencils.visualization.ir.visit.IR_VisItUtil._
case class IR_VisItCommandHandling(cmd : IR_Expression) extends IR_Statement with IR_Expandable {
def step() = {
IR_IfCondition(
stringEquals(cmd, "step"),
ListBuffer[IR_Statement](
IR_FunctionCall(IR_LeveledInternalFunctionReference("simulate_timestep", Knowledge.maxLevel, IR_UnitDatatype)),
IR_IfCondition(
callExtFunction("VisItIsConnected"),
ListBuffer[IR_Statement](
IR_IfCondition(
updatePlots,
ListBuffer[IR_Statement](
callExtFunction("VisItTimeStepChanged"),
callExtFunction("VisItUpdatePlots"))))))
)
}
def stop() = {
IR_IfCondition(stringEquals(cmd, "stop"),
IR_Assignment(runMode, IR_BooleanConstant(false)))
}
def run() = {
IR_IfCondition(stringEquals(cmd, "run"),
IR_Assignment(runMode, IR_BooleanConstant(true)))
}
def toggleUpdates() = {
IR_IfCondition(stringEquals(cmd, "toggle updates"),
IR_Assignment(updatePlots, IR_Negation(updatePlots)))
}
def toggleLevel() = {
IR_IfCondition(
stringEquals(cmd, "toggle level"),
ListBuffer[IR_Statement](
IR_Assignment(curLevel, modulo(curLevel - Knowledge.minLevel - 1, Knowledge.numLevels) + Knowledge.minLevel),
IR_IfCondition(
callExtFunction("VisItIsConnected"),
ListBuffer[IR_Statement](
callExtFunction("VisItTimeStepChanged"),
callExtFunction("VisItUpdatePlots")))))
}
def toggleSlot() = {
IR_IfCondition(
stringEquals(cmd, "toggle slot"),
ListBuffer[IR_Statement](
IR_Assignment(curSlot, (curSlot + 1) Mod IR_FieldCollection.objects.map(_.numSlots).max),
IR_IfCondition(
callExtFunction("VisItIsConnected"),
ListBuffer[IR_Statement](
callExtFunction("VisItTimeStepChanged"),
callExtFunction("VisItUpdatePlots")))))
}
override def expand() : OutputType = {
var stmts = ListBuffer[IR_Statement](step(), stop(), run(), toggleUpdates())
// only register level switches when necessary
if (isMultiLeveled)
stmts += toggleLevel()
// only register slot switch when necessary
if (isMultiSlotted)
stmts += toggleSlot()
stmts
}
}
package exastencils.visualization.ir.interactive.visit
import scala.collection.mutable.ListBuffer
import exastencils.base.ir._
import exastencils.base.ir.IR_ImplicitConversion._
import exastencils.config.Knowledge
import exastencils.datastructures.Transformation.OutputType
import exastencils.field.ir.IR_FieldCollection
import exastencils.visualization.ir.interactive.visit.IR_VisItGlobals._
import exastencils.visualization.ir.interactive.visit.IR_VisItUtil._
case class IR_VisItCommandHandling(cmd : IR_Expression) extends IR_Statement with IR_Expandable {
def step() = {
IR_IfCondition(
stringEquals(cmd, "step"),
ListBuffer[IR_Statement](
IR_FunctionCall(IR_LeveledInternalFunctionReference("simulate_timestep", Knowledge.maxLevel, IR_UnitDatatype)),
IR_IfCondition(
callExtFunction("VisItIsConnected"),
ListBuffer[IR_Statement](
IR_IfCondition(
updatePlots,
ListBuffer[IR_Statement](
callExtFunction("VisItTimeStepChanged"),
callExtFunction("VisItUpdatePlots"))))))
)
}
def stop() = {
IR_IfCondition(stringEquals(cmd, "stop"),
IR_Assignment(runMode, IR_BooleanConstant(false)))
}
def run() = {
IR_IfCondition(stringEquals(cmd, "run"),
IR_Assignment(runMode, IR_BooleanConstant(true)))
}
def toggleUpdates() = {
IR_IfCondition(stringEquals(cmd, "toggle updates"),
IR_Assignment(updatePlots, IR_Negation(updatePlots)))
}
def toggleLevel() = {
IR_IfCondition(
stringEquals(cmd, "toggle level"),
ListBuffer[IR_Statement](
IR_Assignment(curLevel, modulo(curLevel - Knowledge.minLevel - 1, Knowledge.numLevels) + Knowledge.minLevel),
IR_IfCondition(
callExtFunction("VisItIsConnected"),
ListBuffer[IR_Statement](
callExtFunction("VisItTimeStepChanged"),
callExtFunction("VisItUpdatePlots")))))
}
def toggleSlot() = {
IR_IfCondition(
stringEquals(cmd, "toggle slot"),
ListBuffer[IR_Statement](
IR_Assignment(curSlot, (curSlot + 1) Mod IR_FieldCollection.objects.map(_.numSlots).max),
IR_IfCondition(
callExtFunction("VisItIsConnected"),
ListBuffer[IR_Statement](
callExtFunction("VisItTimeStepChanged"),
callExtFunction("VisItUpdatePlots")))))
}
override def expand() : OutputType = {
var stmts = ListBuffer[IR_Statement](step(), stop(), run(), toggleUpdates())
// only register level switches when necessary
if (isMultiLeveled)
stmts += toggleLevel()
// only register slot switch when necessary
if (isMultiSlotted)
stmts += toggleSlot()
stmts
}
}
package exastencils.visualization.ir.visit
import scala.collection.mutable.ListBuffer
import exastencils.base.ir.IR_ImplicitConversion._
import exastencils.base.ir._
import exastencils.visualization.ir.visit.IR_VisItUtil._
import exastencils.config._
case class IR_VisItBroadcastIntCallback() extends IR_VisItFuturePlainFunction {
val intValue = IR_FunctionArgument("value", IR_PointerDatatype(IR_IntegerDatatype))
val sender = IR_FunctionArgument("sender", IR_IntegerDatatype)
override def generateFct() : IR_PlainFunction = {
val fctBody = ListBuffer[IR_Statement]()
fctBody += IR_Return(callExtFunction("MPI_Bcast",
intValue.access, IR_IntegerConstant(1), IR_Native("MPI_INT"), sender.access, Knowledge.mpi_defaultCommunicator))
IR_PlainFunction(
name,
IR_IntegerDatatype,
ListBuffer(intValue, sender),
fctBody
)
}
override def name : String = "visit_broadcast_int_callback"
}
case class IR_VisItBroadcastStringCallback() extends IR_VisItFuturePlainFunction {
val str = IR_FunctionArgument("str", IR_PointerDatatype(IR_CharDatatype))
val len = IR_FunctionArgument("len", IR_IntegerDatatype)
val sender = IR_FunctionArgument("sender", IR_IntegerDatatype)
override def generateFct() : IR_PlainFunction = {
val fctBody = ListBuffer[IR_Statement]()
fctBody += IR_Return(callExtFunction("MPI_Bcast",
str.access, len.access, IR_Native("MPI_CHAR"), sender.access, Knowledge.mpi_defaultCommunicator))
IR_PlainFunction(
name,
IR_IntegerDatatype,