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

Refactor VisIt classes.

parent 20b7a551
......@@ -4,6 +4,7 @@ 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 {
......@@ -13,7 +14,7 @@ case class IR_VisItBroadcastIntCallback() extends IR_VisItFuturePlainFunction {
override def generateFct() : IR_PlainFunction = {
val fctBody = ListBuffer[IR_Statement]()
fctBody += IR_Return(IR_FunctionCall(IR_ExternalFunctionReference("MPI_Bcast"),
fctBody += IR_Return(callExtFunction("MPI_Bcast",
intValue.access, IR_IntegerConstant(1), IR_Native("MPI_INT"), sender.access, Knowledge.mpi_defaultCommunicator))
IR_PlainFunction(
......@@ -36,7 +37,7 @@ case class IR_VisItBroadcastStringCallback() extends IR_VisItFuturePlainFunction
override def generateFct() : IR_PlainFunction = {
val fctBody = ListBuffer[IR_Statement]()
fctBody += IR_Return(IR_FunctionCall(IR_ExternalFunctionReference("MPI_Bcast"),
fctBody += IR_Return(callExtFunction("MPI_Bcast",
str.access, len.access, IR_Native("MPI_CHAR"), sender.access, Knowledge.mpi_defaultCommunicator))
IR_PlainFunction(
......@@ -56,7 +57,7 @@ case class IR_VisItSlaveProcessCallback() extends IR_VisItFuturePlainFunction {
val cmdDecl = IR_VariableDeclaration(IR_IntegerDatatype, "command", IR_IntegerConstant(0))
fctBody += cmdDecl
fctBody += IR_FunctionCall(IR_ExternalFunctionReference("MPI_Bcast"),
fctBody += callExtFunction("MPI_Bcast",
IR_AddressOf(IR_VariableAccess(cmdDecl)), IR_IntegerConstant(1), IR_Native("MPI_INT"), IR_IntegerConstant(0), Knowledge.mpi_defaultCommunicator)
IR_PlainFunction(
......
......@@ -24,13 +24,13 @@ case class IR_VisItControlCommandCallback() extends IR_VisItFuturePlainFunction
ListBuffer[IR_Statement](
IR_FunctionCall(IR_LeveledInternalFunctionReference("simulate_timestep", Knowledge.maxLevel, IR_UnitDatatype)),
IR_IfCondition(
IR_FunctionCall(IR_ExternalFunctionReference("VisItIsConnected")),
callExtFunction("VisItIsConnected"),
ListBuffer[IR_Statement](
IR_IfCondition(
updatePlots,
ListBuffer[IR_Statement](
IR_FunctionCall(IR_ExternalFunctionReference("VisItTimeStepChanged")),
IR_FunctionCall(IR_ExternalFunctionReference("VisItUpdatePlots")))))))
callExtFunction("VisItTimeStepChanged"),
callExtFunction("VisItUpdatePlots"))))))
)
fctBody += IR_IfCondition(
stringEquals(cmd, "stop"),
......@@ -51,20 +51,20 @@ case class IR_VisItControlCommandCallback() extends IR_VisItFuturePlainFunction
ListBuffer[IR_Statement](
IR_Assignment(curLevel, IR_Maximum(curLevel - IR_IntegerConstant(1), Knowledge.minLevel)),
IR_IfCondition(
IR_FunctionCall(IR_ExternalFunctionReference("VisItIsConnected")),
callExtFunction("VisItIsConnected"),
ListBuffer[IR_Statement](
IR_FunctionCall(IR_ExternalFunctionReference("VisItTimeStepChanged")),
IR_FunctionCall(IR_ExternalFunctionReference("VisItUpdatePlots")))))
callExtFunction("VisItTimeStepChanged"),
callExtFunction("VisItUpdatePlots"))))
)
fctBody += IR_IfCondition(
stringEquals(cmd, "level up"),
ListBuffer[IR_Statement](
IR_Assignment(curLevel, IR_Minimum(curLevel + IR_IntegerConstant(1), Knowledge.maxLevel)),
IR_IfCondition(
IR_FunctionCall(IR_ExternalFunctionReference("VisItIsConnected")),
callExtFunction("VisItIsConnected"),
ListBuffer[IR_Statement](
IR_FunctionCall(IR_ExternalFunctionReference("VisItTimeStepChanged")),
IR_FunctionCall(IR_ExternalFunctionReference("VisItUpdatePlots")))))
callExtFunction("VisItTimeStepChanged"),
callExtFunction("VisItUpdatePlots"))))
)
}
......
......@@ -16,7 +16,7 @@ case class IR_VisItDestroy() extends IR_VisItFuturePlainFunction {
val fctBody = ListBuffer[IR_Statement]()
fctBody += IR_FunctionCall(IR_ExternalFunctionReference("VisItCloseTraceFile"))
fctBody += callExtFunction("VisItCloseTraceFile")
// free coords array
if (useRectMesh()) {
......
......@@ -11,7 +11,6 @@ import exastencils.domain.ir._
import exastencils.parallelization.api.mpi._
import exastencils.visualization.ir.visit.IR_VisItGlobals._
case class IR_VisItInitialization() extends IR_VisItFuturePlainFunction {
import exastencils.visualization.ir.visit.IR_VisItUtil._
......@@ -202,7 +201,7 @@ case class IR_VisItInitialization() extends IR_VisItFuturePlainFunction {
}
// set path(top level directory where visit is installed) to select a certain visit version
val strDecl = IR_VariableDeclaration(IR_StringDatatype, "str", IR_FunctionCall(IR_ExternalFunctionReference("std::getenv"), IR_StringConstant("VISIT_HOME")))
val strDecl = IR_VariableDeclaration(IR_StringDatatype, "str", callExtFunction("std::getenv", IR_StringConstant("VISIT_HOME")))
val str = IR_VariableAccess(strDecl)
val pathDecl = IR_VariableDeclaration(IR_PointerDatatype(IR_CharDatatype), "path")
val path = IR_VariableAccess(pathDecl)
......@@ -219,7 +218,7 @@ case class IR_VisItInitialization() extends IR_VisItFuturePlainFunction {
path
),
IR_Assignment(IR_ArrayAccess(path, IR_MemberFunctionCall(str, "size")), IR_Native("\'\\0\'")),
IR_FunctionCall(IR_ExternalFunctionReference("VisItSetDirectory"), path),
callExtFunction("VisItSetDirectory", path),
IR_ArrayFree(path)
)
)
......@@ -234,25 +233,25 @@ case class IR_VisItInitialization() extends IR_VisItFuturePlainFunction {
if (Knowledge.mpi_enabled) {
val fn = IR_VariableAccess("fn", IR_ArrayDatatype(IR_CharDatatype, 1000))
fctBody += IR_VariableDeclaration(fn)
fctBody += IR_FunctionCall(IR_ExternalFunctionReference("sprintf"), fn, IR_StringConstant("trace_%d.txt"), MPI_IV_MpiRank)
fctBody += IR_FunctionCall(IR_ExternalFunctionReference("VisItOpenTraceFile"), fn)
fctBody += callExtFunction("sprintf", fn, IR_StringConstant("trace_%d.txt"), MPI_IV_MpiRank)
fctBody += callExtFunction("VisItOpenTraceFile", fn)
fctBody += IR_FunctionCall(IR_ExternalFunctionReference("VisItSetBroadcastIntFunction"), IR_VisItBroadcastIntCallback().name)
fctBody += IR_FunctionCall(IR_ExternalFunctionReference("VisItSetBroadcastStringFunction"), IR_VisItBroadcastStringCallback().name)
fctBody += callExtFunction("VisItSetBroadcastIntFunction", IR_VisItBroadcastIntCallback().name)
fctBody += callExtFunction("VisItSetBroadcastStringFunction", IR_VisItBroadcastStringCallback().name)
fctBody += IR_FunctionCall(IR_ExternalFunctionReference("VisItSetParallel"), IR_BooleanConstant(true))
fctBody += IR_FunctionCall(IR_ExternalFunctionReference("VisItSetParallelRank"), MPI_IV_MpiRank)
fctBody += callExtFunction("VisItSetParallel", IR_BooleanConstant(true))
fctBody += callExtFunction("VisItSetParallelRank", MPI_IV_MpiRank)
val env = IR_VariableAccess("env", IR_PointerDatatype(IR_CharDatatype))
fctBody += IR_VariableDeclaration(env, nullptr)
fctBody += IR_IfCondition(
MPI_IsRootProc(),
IR_Assignment(env, IR_FunctionCall(IR_ExternalFunctionReference("VisItGetEnvironment")))
IR_Assignment(env, callExtFunction("VisItGetEnvironment"))
)
fctBody += IR_FunctionCall(IR_ExternalFunctionReference("VisItSetupEnvironment2"), env)
fctBody += callExtFunction("VisItSetupEnvironment2", env)
fctBody += IR_IfCondition(
env Neq nullptr,
IR_FunctionCall(IR_ExternalFunctionReference("free"), env)
callExtFunction("free", env)
)
fctBody += IR_IfCondition(
......@@ -261,18 +260,18 @@ case class IR_VisItInitialization() extends IR_VisItFuturePlainFunction {
IR_VariableDeclaration(cwd, nullptr),
IR_ArrayAllocation(cwd, IR_CharDatatype, IR_IntegerConstant(1000)),
IR_Assignment(cwd, IR_FunctionCall(getCWD, cwd, IR_IntegerConstant(1000))),
IR_FunctionCall(IR_ExternalFunctionReference("VisItInitializeSocketAndDumpSimFile"), IR_StringConstant(simName.head),
callExtFunction("VisItInitializeSocketAndDumpSimFile", IR_StringConstant(simName.head),
IR_StringConstant(simName.tail.mkString("_")), cwd, nullptr, nullptr, nullptr),
IR_ArrayFree(cwd)
)
)
} else {
fctBody += IR_FunctionCall(IR_ExternalFunctionReference("VisItOpenTraceFile"), IR_StringConstant("trace.txt"))
fctBody += IR_FunctionCall(IR_ExternalFunctionReference("VisItSetupEnvironment"))
fctBody += callExtFunction("VisItOpenTraceFile", IR_StringConstant("trace.txt"))
fctBody += callExtFunction("VisItSetupEnvironment")
fctBody += IR_VariableDeclaration(cwd, nullptr)
fctBody += IR_ArrayAllocation(cwd, IR_CharDatatype, IR_IntegerConstant(1000))
fctBody += IR_Assignment(cwd, IR_FunctionCall(getCWD, cwd, IR_IntegerConstant(1000)))
fctBody += IR_FunctionCall(IR_ExternalFunctionReference("VisItInitializeSocketAndDumpSimFile"),
fctBody += callExtFunction("VisItInitializeSocketAndDumpSimFile",
IR_StringConstant(simName.head), IR_StringConstant(simName.tail.mkString("_")), cwd, nullptr, nullptr, nullptr)
fctBody += IR_ArrayFree(cwd)
}
......
......@@ -8,7 +8,6 @@ import exastencils.config._
import exastencils.parallelization.api.mpi._
import exastencils.visualization.ir.visit.IR_VisItGlobals._
case class IR_VisItMainloop() extends IR_VisItFuturePlainFunction {
import exastencils.visualization.ir.visit.IR_VisItUtil._
......@@ -25,23 +24,23 @@ case class IR_VisItMainloop() extends IR_VisItFuturePlainFunction {
val registerCallbackFcts = ListBuffer[IR_Statement]()
val procEngineCommandFct = if (Knowledge.mpi_enabled) {
IR_FunctionCall(IR_ExternalFunctionReference("ProcessVisItCommand"))
callExtFunction("ProcessVisItCommand")
} else {
IR_FunctionCall(IR_ExternalFunctionReference("VisItProcessEngineCommand"))
callExtFunction("VisItProcessEngineCommand")
}
// callback functions to register
if (Knowledge.mpi_enabled) {
registerCallbackFcts += IR_FunctionCall(IR_ExternalFunctionReference("VisItSetSlaveProcessCallback"), IR_Native("slave_process_callback"))
registerCallbackFcts += IR_FunctionCall(IR_ExternalFunctionReference("VisItSetGetDomainList"), IR_Native("SimGetDomainList"), nullptr)
registerCallbackFcts += callExtFunction("VisItSetSlaveProcessCallback", IR_Native("slave_process_callback"))
registerCallbackFcts += callExtFunction("VisItSetGetDomainList", IR_Native("SimGetDomainList"), nullptr)
}
registerCallbackFcts += IR_FunctionCall(IR_ExternalFunctionReference("VisItSetGetMetaData"), IR_Native("SimGetMetaData"), nullptr)
registerCallbackFcts += IR_FunctionCall(IR_ExternalFunctionReference("VisItSetGetMesh"), IR_Native("SimGetMesh"), nullptr)
registerCallbackFcts += callExtFunction("VisItSetGetMetaData", IR_Native("SimGetMetaData"), nullptr)
registerCallbackFcts += callExtFunction("VisItSetGetMesh", IR_Native("SimGetMesh"), nullptr)
if (Knowledge.dimensionality > 1) { // 1d variables are pictured as meshes
registerCallbackFcts += IR_FunctionCall(IR_ExternalFunctionReference("VisItSetGetVariable"), IR_Native("SimGetVariable"), nullptr)
registerCallbackFcts += callExtFunction("VisItSetGetVariable", IR_Native("SimGetVariable"), nullptr)
}
registerCallbackFcts += IR_FunctionCall(IR_ExternalFunctionReference("VisItSetCommandCallback"), IR_Native("ControlCommandCallback"), nullptr)
registerCallbackFcts += callExtFunction("VisItSetCommandCallback", IR_Native("ControlCommandCallback"), nullptr)
// body of the while loop containing the switch statement
whileBody += IR_IfCondition(
......@@ -60,11 +59,11 @@ case class IR_VisItMainloop() extends IR_VisItFuturePlainFunction {
whileBody += IR_VariableDeclaration(visitInput)
whileBody += IR_IfCondition(
MPI_IsRootProc.apply(),
IR_Assignment(visitInput, IR_FunctionCall(IR_ExternalFunctionReference("VisItDetectInput"), blocking, IR_FunctionCall(funcRef, IR_Native("stdin"))))
IR_Assignment(visitInput, callExtFunction("VisItDetectInput", blocking, IR_FunctionCall(funcRef, IR_Native("stdin"))))
)
whileBody += IR_FunctionCall(IR_ExternalFunctionReference("MPI_Bcast"), IR_AddressOf(visitInput), IR_IntegerConstant(1), IR_Native("MPI_INT"), IR_IntegerConstant(0), Knowledge.mpi_defaultCommunicator)
whileBody += callExtFunction("MPI_Bcast", IR_AddressOf(visitInput), IR_IntegerConstant(1), IR_Native("MPI_INT"), IR_IntegerConstant(0), Knowledge.mpi_defaultCommunicator)
} else {
whileBody += IR_VariableDeclaration(visitInput, IR_FunctionCall(IR_ExternalFunctionReference("VisItDetectInput"), blocking, IR_FunctionCall(funcRef, IR_Native("stdin"))))
whileBody += IR_VariableDeclaration(visitInput, callExtFunction("VisItDetectInput", blocking, IR_FunctionCall(funcRef, IR_Native("stdin"))))
}
// body of the third case of the switch statement
......@@ -75,14 +74,14 @@ case class IR_VisItMainloop() extends IR_VisItFuturePlainFunction {
consoleInputBody += IR_IfCondition(
MPI_IsRootProc.apply(),
IR_IfCondition(
IR_FunctionCall(IR_ExternalFunctionReference("VisItReadConsole"), IR_IntegerConstant(1000), command) Neq visitOkay,
callExtFunction("VisItReadConsole", IR_IntegerConstant(1000), command) Neq visitOkay,
IR_Break()
)
)
consoleInputBody += IR_FunctionCall(IR_ExternalFunctionReference("MPI_Bcast"), command, IR_IntegerConstant(1000), IR_Native("MPI_CHAR"), IR_IntegerConstant(0), Knowledge.mpi_defaultCommunicator)
consoleInputBody += callExtFunction("MPI_Bcast", command, IR_IntegerConstant(1000), IR_Native("MPI_CHAR"), IR_IntegerConstant(0), Knowledge.mpi_defaultCommunicator)
} else {
consoleInputBody += IR_IfCondition(
IR_FunctionCall(IR_ExternalFunctionReference("VisItReadConsole"), IR_IntegerConstant(1000), command) Neq visitOkay,
callExtFunction("VisItReadConsole", IR_IntegerConstant(1000), command) Neq visitOkay,
IR_Break()
)
}
......@@ -93,13 +92,13 @@ case class IR_VisItMainloop() extends IR_VisItFuturePlainFunction {
ListBuffer[IR_Statement](
IR_FunctionCall(IR_LeveledInternalFunctionReference("simulate_timestep", Knowledge.maxLevel, IR_UnitDatatype)),
IR_IfCondition(
IR_FunctionCall(IR_ExternalFunctionReference("VisItIsConnected")),
callExtFunction("VisItIsConnected"),
ListBuffer[IR_Statement](
IR_IfCondition(
updatePlots,
ListBuffer[IR_Statement](
IR_FunctionCall(IR_ExternalFunctionReference("VisItTimeStepChanged")),
IR_FunctionCall(IR_ExternalFunctionReference("VisItUpdatePlots"))))))))
callExtFunction("VisItTimeStepChanged"),
callExtFunction("VisItUpdatePlots")))))))
consoleInputBody += IR_IfCondition(
stringEquals(command, "stop"),
......@@ -120,7 +119,7 @@ case class IR_VisItMainloop() extends IR_VisItFuturePlainFunction {
if (Knowledge.dimensionality == 1 || Knowledge.dimensionality == 2) {
val strToReal = if (Knowledge.useDblPrecision) "std::stod" else "std::stof"
consoleInputBody += IR_IfCondition(
IR_FunctionCall(IR_ExternalFunctionReference("strstr"), command, IR_StringConstant("scale=")) Neq nullptr,
callExtFunction("strstr", command, IR_StringConstant("scale=")) Neq nullptr,
IR_Native(
s"""|try{
|scale = $strToReal(command+6);
......@@ -140,20 +139,20 @@ case class IR_VisItMainloop() extends IR_VisItFuturePlainFunction {
ListBuffer[IR_Statement](
IR_Assignment(curLevel, IR_Maximum(curLevel - IR_IntegerConstant(1), Knowledge.minLevel)),
IR_IfCondition(
IR_FunctionCall(IR_ExternalFunctionReference("VisItIsConnected")),
callExtFunction("VisItIsConnected"),
ListBuffer[IR_Statement](
IR_FunctionCall(IR_ExternalFunctionReference("VisItTimeStepChanged")),
IR_FunctionCall(IR_ExternalFunctionReference("VisItUpdatePlots"))))))
callExtFunction("VisItTimeStepChanged"),
callExtFunction("VisItUpdatePlots")))))
consoleInputBody += IR_IfCondition(
stringEquals(command, "level up"),
ListBuffer[IR_Statement](
IR_Assignment(curLevel, IR_Minimum(curLevel + IR_IntegerConstant(1), Knowledge.maxLevel)),
IR_IfCondition(
IR_FunctionCall(IR_ExternalFunctionReference("VisItIsConnected")),
callExtFunction("VisItIsConnected"),
ListBuffer[IR_Statement](
IR_FunctionCall(IR_ExternalFunctionReference("VisItTimeStepChanged")),
IR_FunctionCall(IR_ExternalFunctionReference("VisItUpdatePlots"))))))
callExtFunction("VisItTimeStepChanged"),
callExtFunction("VisItUpdatePlots")))))
}
consoleInputBody += IR_ArrayFree(command)
......@@ -167,16 +166,16 @@ case class IR_VisItMainloop() extends IR_VisItFuturePlainFunction {
ListBuffer[IR_Statement](
IR_FunctionCall(IR_LeveledInternalFunctionReference("simulate_timestep", Knowledge.maxLevel, IR_UnitDatatype)),
IR_IfCondition(
IR_FunctionCall(IR_ExternalFunctionReference("VisItIsConnected")),
callExtFunction("VisItIsConnected"),
ListBuffer[IR_Statement](
IR_FunctionCall(IR_ExternalFunctionReference("VisItTimeStepChanged")),
callExtFunction("VisItTimeStepChanged"),
IR_IfCondition(
updatePlots,
IR_FunctionCall(IR_ExternalFunctionReference("VisItUpdatePlots")))))))
callExtFunction("VisItUpdatePlots"))))))
whileBody += IR_IfCondition(visitInput EqEq IR_IntegerConstant(1), // inbound connection is being made
IR_IfCondition(
IR_FunctionCall(IR_ExternalFunctionReference("VisItAttemptToCompleteConnection")),
callExtFunction("VisItAttemptToCompleteConnection"),
registerCallbackFcts,
IR_Native("std::cout << \"Visit connection failed. Error message: \" << VisItGetLastError() << std::endl")))
......@@ -185,7 +184,7 @@ case class IR_VisItMainloop() extends IR_VisItFuturePlainFunction {
IR_IfCondition(
procEngineCommandFct Neq IR_BooleanConstant(true),
ListBuffer[IR_Statement](
IR_FunctionCall(IR_ExternalFunctionReference("VisItDisconnect")),
callExtFunction("VisItDisconnect"),
IR_Assignment(runMode, IR_BooleanConstant(true))))) // run after VisIt closes connection
whileBody += IR_IfCondition(
......@@ -204,7 +203,6 @@ case class IR_VisItMainloop() extends IR_VisItFuturePlainFunction {
fctBody
)
}
override def name : String = "visit_mainloop"
}
......@@ -6,13 +6,14 @@ import exastencils.base.ir.IR_ImplicitConversion._
import exastencils.base.ir._
import exastencils.config._
import exastencils.parallelization.api.mpi._
import exastencils.visualization.ir.visit.IR_VisItUtil.callExtFunction
/// IR_VisItProcessVisItCommand
// additional handling for parallel simulations because only root communicates with VisIt
case class IR_VisItProcessVisItCommand() extends IR_VisItFuturePlainFunction {
override def generateFct() : IR_PlainFunction = {
override def generateFct() : IR_PlainFunction = {
val fctBody = ListBuffer[IR_Statement]()
val command = IR_VariableAccess("command", IR_IntegerDatatype)
......@@ -22,14 +23,14 @@ case class IR_VisItProcessVisItCommand() extends IR_VisItFuturePlainFunction {
MPI_IsRootProc.apply(),
ListBuffer[IR_Statement](
IR_IfCondition(
IR_EqEq(1, IR_FunctionCall(IR_ExternalFunctionReference("VisItProcessEngineCommand"))),
IR_EqEq(1, callExtFunction("VisItProcessEngineCommand")),
ListBuffer[IR_Statement](
IR_Assignment(command, 1),
IR_FunctionCall(IR_ExternalFunctionReference("MPI_Bcast"), IR_AddressOf(command), 1, IR_Native("MPI_INT"), 0, Knowledge.mpi_defaultCommunicator),
callExtFunction("MPI_Bcast", IR_AddressOf(command), 1, IR_Native("MPI_INT"), 0, Knowledge.mpi_defaultCommunicator),
IR_Return(1)),
ListBuffer[IR_Statement](
IR_Assignment(command, 0),
IR_FunctionCall(IR_ExternalFunctionReference("MPI_Bcast"), IR_AddressOf(command), 1, IR_Native("MPI_INT"), 0, Knowledge.mpi_defaultCommunicator),
callExtFunction("MPI_Bcast", IR_AddressOf(command), 1, IR_Native("MPI_INT"), 0, Knowledge.mpi_defaultCommunicator),
IR_Return(0))
)
),
......@@ -37,10 +38,10 @@ case class IR_VisItProcessVisItCommand() extends IR_VisItFuturePlainFunction {
IR_WhileLoop(
1,
ListBuffer[IR_Statement](
IR_FunctionCall(IR_ExternalFunctionReference("MPI_Bcast"), IR_AddressOf(command), 1, IR_Native("MPI_INT"), 0, Knowledge.mpi_defaultCommunicator),
callExtFunction("MPI_Bcast", IR_AddressOf(command), 1, IR_Native("MPI_INT"), 0, Knowledge.mpi_defaultCommunicator),
IR_IfCondition(
IR_EqEq(command, 0),
IR_FunctionCall(IR_ExternalFunctionReference("VisItProcessEngineCommand"))),
callExtFunction("VisItProcessEngineCommand")),
IR_IfCondition(
IR_EqEq(command, 1),
IR_Return(1)),
......
......@@ -7,6 +7,7 @@ import exastencils.base.ir._
import exastencils.config._
import exastencils.parallelization.api.mpi._
import exastencils.visualization.ir.visit.IR_VisItGlobals._
import exastencils.visualization.ir.visit.IR_VisItUtil.callExtFunction
/// IR_VisItSimGetDomainList
......@@ -15,7 +16,7 @@ import exastencils.visualization.ir.visit.IR_VisItGlobals._
case class IR_VisItSimGetDomainList() extends IR_VisItFuturePlainFunction {
override def generateFct() : IR_PlainFunction = {
override def generateFct() : IR_PlainFunction = {
val fctBody = ListBuffer[IR_Statement]()
val h = IR_VariableAccess("h", visitHandle)
val domainList = IR_VariableAccess("domain_list", visitHandle)
......@@ -25,11 +26,11 @@ case class IR_VisItSimGetDomainList() extends IR_VisItFuturePlainFunction {
fctBody += IR_IfCondition(
IR_AndAnd(
IR_EqEq(IR_FunctionCall(IR_ExternalFunctionReference("VisIt_DomainList_alloc"), IR_AddressOf(h)), visitOkay),
IR_EqEq(IR_FunctionCall(IR_ExternalFunctionReference("VisIt_VariableData_alloc"), IR_AddressOf(domainList)), visitOkay)),
IR_EqEq(callExtFunction("VisIt_DomainList_alloc", IR_AddressOf(h)), visitOkay),
IR_EqEq(callExtFunction("VisIt_VariableData_alloc", IR_AddressOf(domainList)), visitOkay)),
ListBuffer[IR_Statement](
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_VariableData_setDataI"), domainList, IR_Native("VISIT_OWNER_COPY"), IR_IntegerConstant(1), IR_IntegerConstant(1), IR_AddressOf(MPI_IV_MpiRank)),
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_DomainList_setDomains"), h, Knowledge.mpi_numThreads, domainList))
callExtFunction("VisIt_VariableData_setDataI", domainList, IR_Native("VISIT_OWNER_COPY"), IR_IntegerConstant(1), IR_IntegerConstant(1), IR_AddressOf(MPI_IV_MpiRank)),
callExtFunction("VisIt_DomainList_setDomains", h, Knowledge.mpi_numThreads, domainList))
)
fctBody += IR_Return(h)
......
......@@ -36,20 +36,20 @@ case class IR_VisItSimGetMesh() extends IR_VisItFuturePlainFunction {
// coordinate setter function depending on dimensionality
val handlesAccessDim = (0 until Knowledge.dimensionality).map(d => IR_ArrayAccess(handles, d)).toArray
val funcCall = if (Knowledge.dimensionality == 2) {
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_RectilinearMesh_setCoordsXY"), h, handlesAccessDim(0), handlesAccessDim(1))
callExtFunction("VisIt_RectilinearMesh_setCoordsXY", h, handlesAccessDim(0), handlesAccessDim(1))
} else {
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_RectilinearMesh_setCoordsXYZ"), h, handlesAccessDim(0), handlesAccessDim(1), handlesAccessDim(2))
callExtFunction("VisIt_RectilinearMesh_setCoordsXYZ", h, handlesAccessDim(0), handlesAccessDim(1), handlesAccessDim(2))
}
val ifBody = ListBuffer[IR_Statement]()
// allocate handles
ifBody += IR_VariableDeclaration(handles)
for (dim <- 0 until Knowledge.dimensionality) {
ifBody += IR_FunctionCall(IR_ExternalFunctionReference("VisIt_VariableData_alloc"), IR_AddressOf(IR_ArrayAccess(handles, dim)))
ifBody += callExtFunction("VisIt_VariableData_alloc", IR_AddressOf(IR_ArrayAccess(handles, dim)))
}
// determine whether doubles or floats are sent
val funcRef = if (Knowledge.useDblPrecision) IR_ExternalFunctionReference("VisIt_VariableData_setDataD") else IR_ExternalFunctionReference("VisIt_VariableData_setDataF")
val funcRef = IR_ExternalFunctionReference("VisIt_VariableData_setData" + (if (Knowledge.useDblPrecision) "D" else "F"))
// pass pointers of coordinate arrays to handles
for (dim <- 0 until Knowledge.dimensionality) {
......@@ -77,7 +77,7 @@ case class IR_VisItSimGetMesh() extends IR_VisItFuturePlainFunction {
),
ListBuffer[IR_Statement](
IR_IfCondition(
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_RectilinearMesh_alloc"), IR_AddressOf(h)) EqEq visitOkay,
callExtFunction("VisIt_RectilinearMesh_alloc", IR_AddressOf(h)) EqEq visitOkay,
ifBody))
)
}
......@@ -110,15 +110,15 @@ case class IR_VisItSimGetMesh() extends IR_VisItFuturePlainFunction {
ifBody += IR_Assignment(IR_ArrayAccess(dims, numDims), 1)
val funcCall = if (numDims == 1) {
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_CurvilinearMesh_setCoordsXY"), h, dims, IR_ArrayAccess(handlesCurve, 0), IR_ArrayAccess(handlesCurve, 1))
callExtFunction("VisIt_CurvilinearMesh_setCoordsXY", h, dims, IR_ArrayAccess(handlesCurve, 0), IR_ArrayAccess(handlesCurve, 1))
} else {
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_CurvilinearMesh_setCoordsXYZ"), h, dims, IR_ArrayAccess(handlesCurve, 0), IR_ArrayAccess(handlesCurve, 1), IR_ArrayAccess(handlesCurve, 2))
callExtFunction("VisIt_CurvilinearMesh_setCoordsXYZ", h, dims, IR_ArrayAccess(handlesCurve, 0), IR_ArrayAccess(handlesCurve, 1), IR_ArrayAccess(handlesCurve, 2))
}
// allocate handles
ifBody += IR_VariableDeclaration(handlesCurve)
for (dim <- 0 to numDims) {
ifBody += IR_FunctionCall(IR_ExternalFunctionReference("VisIt_VariableData_alloc"), IR_AddressOf(IR_ArrayAccess(handles, dim)))
ifBody += callExtFunction("VisIt_VariableData_alloc", IR_AddressOf(IR_ArrayAccess(handles, dim)))
}
// pass pointers of coordinate arrays to handles
......@@ -197,7 +197,7 @@ case class IR_VisItSimGetMesh() extends IR_VisItFuturePlainFunction {
),
ListBuffer[IR_Statement](
IR_IfCondition(
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_CurvilinearMesh_alloc"), IR_AddressOf(h)) EqEq visitOkay,
callExtFunction("VisIt_CurvilinearMesh_alloc", IR_AddressOf(h)) EqEq visitOkay,
ifBody
)
)
......
......@@ -18,7 +18,7 @@ case class IR_VisItSimGetMetaData() extends IR_VisItFuturePlainFunction {
import exastencils.visualization.ir.visit.IR_VisItUtil._
override def generateFct() : IR_PlainFunction = {
override def generateFct() : IR_PlainFunction = {
val fctBody = ListBuffer[IR_Statement]()
val ifBody = ListBuffer[IR_Statement]()
......@@ -29,8 +29,8 @@ case class IR_VisItSimGetMetaData() extends IR_VisItFuturePlainFunction {
/* simulation metadata(mode, time, cycle) */
val modeDecl = IR_VariableDeclaration(IR_IntegerDatatype, "mode", IR_TernaryCondition(runMode, IR_Native("VISIT_SIMMODE_RUNNING"), IR_Native("VISIT_SIMMODE_STOPPED")))
ifBody += modeDecl
ifBody += IR_FunctionCall(IR_ExternalFunctionReference("VisIt_SimulationMetaData_setMode"), md, IR_VariableAccess(modeDecl))
ifBody += IR_FunctionCall(IR_ExternalFunctionReference("VisIt_SimulationMetaData_setCycleTime"), md, simCycle, simTime)
ifBody += callExtFunction("VisIt_SimulationMetaData_setMode", md, IR_VariableAccess(modeDecl))
ifBody += callExtFunction("VisIt_SimulationMetaData_setCycleTime", md, simCycle, simTime)
/* mesh metadata */
if (Knowledge.dimensionality > 1) {
......@@ -39,14 +39,14 @@ case class IR_VisItSimGetMetaData() extends IR_VisItFuturePlainFunction {
ifBody += IR_VariableDeclaration(mmd, visitInvalidHandle)
ifBody += IR_IfCondition(
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_MeshMetaData_alloc"), IR_AddressOf(mmd)) EqEq visitOkay,
callExtFunction("VisIt_MeshMetaData_alloc", IR_AddressOf(mmd)) EqEq visitOkay,
ListBuffer[IR_Statement](
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_MeshMetaData_setName"), mmd, IR_StringConstant(meshname(coords))),
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_MeshMetaData_setMeshType"), mmd, IR_Native("VISIT_MESHTYPE_RECTILINEAR")),
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_MeshMetaData_setTopologicalDimension"), mmd, Knowledge.dimensionality),
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_MeshMetaData_setSpatialDimension"), mmd, Knowledge.dimensionality),
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_MeshMetaData_setNumDomains"), mmd, Knowledge.domain_numBlocks),
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_SimulationMetaData_addMesh"), md, mmd))
callExtFunction("VisIt_MeshMetaData_setName", mmd, IR_StringConstant(meshname(coords))),
callExtFunction("VisIt_MeshMetaData_setMeshType", mmd, IR_Native("VISIT_MESHTYPE_RECTILINEAR")),
callExtFunction("VisIt_MeshMetaData_setTopologicalDimension", mmd, Knowledge.dimensionality),
callExtFunction("VisIt_MeshMetaData_setSpatialDimension", mmd, Knowledge.dimensionality),
callExtFunction("VisIt_MeshMetaData_setNumDomains", mmd, Knowledge.domain_numBlocks),
callExtFunction("VisIt_SimulationMetaData_addMesh", md, mmd))
)
}
}
......@@ -59,14 +59,14 @@ case class IR_VisItSimGetMetaData() extends IR_VisItFuturePlainFunction {
ifBody += IR_VariableDeclaration(mmd, visitInvalidHandle)
ifBody += IR_IfCondition(
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_MeshMetaData_alloc"), IR_AddressOf(mmd)) EqEq visitOkay,
callExtFunction("VisIt_MeshMetaData_alloc", IR_AddressOf(mmd)) EqEq visitOkay,
ListBuffer[IR_Statement](
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_MeshMetaData_setName"), mmd, IR_StringConstant(curvname(Knowledge.dimensionality, field.name))),
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_MeshMetaData_setMeshType"), mmd, IR_Native("VISIT_MESHTYPE_CURVILINEAR")),
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_MeshMetaData_setTopologicalDimension"), mmd, Knowledge.dimensionality + 1),
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_MeshMetaData_setSpatialDimension"), mmd, Knowledge.dimensionality + 1),
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_MeshMetaData_setNumDomains"), mmd, Knowledge.domain_numBlocks),
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_SimulationMetaData_addMesh"), md, mmd))
callExtFunction("VisIt_MeshMetaData_setName", mmd, IR_StringConstant(curvname(Knowledge.dimensionality, field.name))),
callExtFunction("VisIt_MeshMetaData_setMeshType", mmd, IR_Native("VISIT_MESHTYPE_CURVILINEAR")),
callExtFunction("VisIt_MeshMetaData_setTopologicalDimension", mmd, Knowledge.dimensionality + 1),
callExtFunction("VisIt_MeshMetaData_setSpatialDimension", mmd, Knowledge.dimensionality + 1),
callExtFunction("VisIt_MeshMetaData_setNumDomains", mmd, Knowledge.domain_numBlocks),
callExtFunction("VisIt_SimulationMetaData_addMesh", md, mmd))
)
newNameIdentifier = field.name
}
......@@ -87,13 +87,13 @@ case class IR_VisItSimGetMetaData() extends IR_VisItFuturePlainFunction {
ifBody += IR_VariableDeclaration(vmd, visitInvalidHandle)
ifBody += IR_IfCondition(
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_VariableMetaData_alloc"), IR_AddressOf(vmd)) EqEq visitOkay,
callExtFunction("VisIt_VariableMetaData_alloc", IR_AddressOf(vmd)) EqEq visitOkay,
ListBuffer[IR_Statement](
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_VariableMetaData_setName"), vmd, IR_StringConstant(field.name)),
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_VariableMetaData_setMeshName"), vmd, IR_StringConstant(meshname(field))),
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_VariableMetaData_setType"), vmd, IR_Native("VISIT_VARTYPE_SCALAR")),
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_VariableMetaData_setCentering"), vmd, varCentering),
IR_FunctionCall(IR_ExternalFunctionReference("VisIt_SimulationMetaData_addVariable"), md, vmd))
callExtFunction("VisIt_VariableMetaData_setName", vmd, IR_StringConstant(field.name)),
callExtFunction("VisIt_VariableMetaData_setMeshName", vmd, IR_StringConstant(meshname(field))),
callExtFunction("VisIt_VariableMetaData_setType", vmd, IR_Native("VISIT_VARTYPE_SCALAR")),
callExtFunction("VisIt_VariableMetaData_setCentering", vmd, varCentering),
callExtFunction("VisIt_SimulationMetaData_addVariable", md, vmd))