Skip to content

Commit

Permalink
Merge pull request #130 from JustinBonus/master
Browse files Browse the repository at this point in the history
Update MPM OSU-LWF twin example, update CelerisTaichiEvent, and add local build script
  • Loading branch information
fmckenna authored Dec 5, 2024
2 parents b33db6a + be5eb0d commit aafdbfc
Show file tree
Hide file tree
Showing 19 changed files with 1,421 additions and 224 deletions.
42 changes: 41 additions & 1 deletion EVENTS/HydroEventSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <WaveDigitalFlume/WaveDigitalFlume.h>
#include <coupledDigitalTwin/CoupledDigitalTwin.h>
#include <MPM/MPM.h>
#include <MPMEvent/MPMEvent.h>
#include <StochasticWaveModel/include/StochasticWaveInput.h>
#include <TaichiEvent/TaichiEvent.h>
#include <TaichiEvent/CelerisTaichiEvent.h>
#include <MPM/SPH.h>
//*********************************************************************************
// Main Hydro event
Expand All @@ -78,7 +80,9 @@ enum class Event_b : bool {
WaveDigitalFlume_b = false,
CoupledDigitalTwin_b = true,
ClaymoreUW_b = true,
BasicClaymoreUW_b = true,
TaichiEvent_b = true,
CelerisTaichiEvent_b = true,
StochasticWaves_b = true,
SPH_b = false
};
Expand All @@ -88,8 +92,10 @@ enum class Event_e : int {
GeoClawOpenFOAM_e = Start_e,
WaveDigitalFlume_e,
CoupledDigitalTwin_e,
ClaymoreUW_e,
ClaymoreUW_e,
BasicClaymoreUW_e,
TaichiEvent_e,
CelerisTaichiEvent_e,
StochasticWaves_e,
SPH_e,
Last_e, // For C++ iteration
Expand All @@ -101,7 +107,9 @@ const int EventSelectionIndexArray[] = {
static_cast<int>(Event_e::WaveDigitalFlume_e),
static_cast<int>(Event_e::CoupledDigitalTwin_e),
static_cast<int>(Event_e::ClaymoreUW_e),
static_cast<int>(Event_e::BasicClaymoreUW_e),
static_cast<int>(Event_e::TaichiEvent_e),
static_cast<int>(Event_e::CelerisTaichiEvent_e),
static_cast<int>(Event_e::StochasticWaves_e),
static_cast<int>(Event_e::SPH_e)
};
Expand All @@ -111,7 +119,9 @@ const bool EventSelectionEnabledArray[] = {
static_cast<bool>(Event_b::WaveDigitalFlume_b),
static_cast<bool>(Event_b::CoupledDigitalTwin_b),
static_cast<bool>(Event_b::ClaymoreUW_b),
static_cast<bool>(Event_b::BasicClaymoreUW_b),
static_cast<bool>(Event_b::TaichiEvent_b),
static_cast<bool>(Event_b::CelerisTaichiEvent_b),
static_cast<bool>(Event_b::StochasticWaves_b),
static_cast<bool>(Event_b::SPH_b)
};
Expand All @@ -121,7 +131,9 @@ const QString EventSelectionStringArray[] = {
static_cast<QString>("WaveDigitalFlume"),
static_cast<QString>("CoupledDigitalTwin"),
static_cast<QString>("MPM"),
static_cast<QString>("MPMEvent"),
static_cast<QString>("TaichiEvent"),
static_cast<QString>("CelerisTaichiEvent"),
static_cast<QString>("StochasticWave"),
static_cast<QString>("SPH")
};
Expand All @@ -131,7 +143,9 @@ const QString EventSelectionDisplayArray[] = {
"Digital Twin (GeoClaw and OpenFOAM)",
"Digital Twin (OpenFOAM and OpenSees)",
"Digital Twin (MPM)",
"General Event (MPM)",
"General Event (Taichi)",
"General Event (Celeris)",
"Stochastic Wave Loading",
"Digital Twin (SPH)"
};
Expand All @@ -141,7 +155,9 @@ const QString EventSelectionToolTipArray[] = {
"Shallow-Water-Equations -> Finite-Volume-Method -> Finite-Element-Analysis (GeoClaw -> OpenFOAM -> OpenSees) [Multi-CPU]",
"Finite-Volume-Method <-> Finite-Element-Analysis (OpenFOAM <-> OpenSees) [Multi-CPU]",
"Material-Point-Method (ClaymoreUW MPM) [Multi-GPU]",
"Material-Point-Method JSON Input (ClaymoreUW MPM) [Multi-GPU]",
"Taichi Numerical Simulation (Taichi Lang) [CPU-GPU]",
"Wave-Solver (Celeris) [CPU-GPU]",
"Stochastic Wave Loading By Sea-State Spectra (welib) [CPU]",
"Smoothed-Particle-Hydrodynamics (DualSPHysics) [CPU-GPU]"
};
Expand Down Expand Up @@ -229,10 +245,18 @@ HydroEventSelection::HydroEventSelection(RandomVariablesContainer *theRandomVari
theMPM = new MPM(theRandomVariablesContainer);
theStackedWidget->addWidget(theMPM);
break;
case (Event_e::BasicClaymoreUW_e):
theMPMEvent = new MPMEvent(theRandomVariablesContainer);
theStackedWidget->addWidget(theMPMEvent);
break;
case (Event_e::TaichiEvent_e):
theTaichiEvent = new TaichiEvent(theRandomVariablesContainer);
theStackedWidget->addWidget(theTaichiEvent);
break;
case (Event_e::CelerisTaichiEvent_e):
theCelerisTaichiEvent = new CelerisTaichiEvent(theRandomVariablesContainer);
theStackedWidget->addWidget(theCelerisTaichiEvent);
break;
case (Event_e::StochasticWaves_e):
theStochasticWaves = new StochasticWaveInput(theRandomVariablesContainer);
theStackedWidget->addWidget(theStochasticWaves);
Expand Down Expand Up @@ -279,9 +303,15 @@ HydroEventSelection::HydroEventSelection(RandomVariablesContainer *theRandomVari
if constexpr (indexDefault == Event_e::ClaymoreUW_e) {
theCurrentEvent = theMPM;
}
if constexpr (indexDefault == Event_e::BasicClaymoreUW_e) {
theCurrentEvent = theMPMEvent;
}
if constexpr (indexDefault == Event_e::TaichiEvent_e) {
theCurrentEvent = theTaichiEvent;
}
if constexpr (indexDefault == Event_e::CelerisTaichiEvent_e) {
theCurrentEvent = theCelerisTaichiEvent;
}
if constexpr (indexDefault == Event_e::StochasticWaves_e) {
theCurrentEvent = theStochasticWaves;
}
Expand Down Expand Up @@ -372,11 +402,21 @@ void HydroEventSelection::eventSelectionChanged(int arg1)
// theCurrentEvent = theMPM;
}
}
if constexpr (static_cast<bool>(Event_b::BasicClaymoreUW_b)) {
if (arg1 == static_cast<int>(Event_e::BasicClaymoreUW_e)) {
theCurrentEvent = theMPMEvent;
}
}
if constexpr (static_cast<bool>(Event_b::TaichiEvent_b)) {
if (arg1 == static_cast<int>(Event_e::TaichiEvent_e)) {
theCurrentEvent = theTaichiEvent;
}
}
if constexpr (static_cast<bool>(Event_b::CelerisTaichiEvent_b)) {
if (arg1 == static_cast<int>(Event_e::CelerisTaichiEvent_e)) {
theCurrentEvent = theCelerisTaichiEvent;
}
}
if constexpr (static_cast<bool>(Event_b::StochasticWaves_b)) {
if (arg1 == static_cast<int>(Event_e::StochasticWaves_e)) {
theCurrentEvent = theStochasticWaves;
Expand Down
2 changes: 2 additions & 0 deletions EVENTS/HydroEventSelection.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ public slots:
SimCenterAppWidget *theWaveDigitalFlume;
SimCenterAppWidget *theCoupledDigitalTwin;
SimCenterAppWidget *theMPM;
SimCenterAppWidget *theMPMEvent;
SimCenterAppWidget *theTaichiEvent;
SimCenterAppWidget *theCelerisTaichiEvent;
SimCenterAppWidget *theStochasticWaves;
SimCenterAppWidget *theSPH;
SimCenterAppWidget *theExistingEvents;
Expand Down
6 changes: 3 additions & 3 deletions EVENTS/MPM/BodiesMPM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,12 @@ BodiesMPM::BodiesMPM(QWidget *parent)
}

// Set initial algorithm preset
fluidAlgorithm->enableASFLIP(true);
fluidAlgorithm->enableASFLIP(false);
fluidAlgorithm->setASFLIP_alpha(0.0);
fluidAlgorithm->setASFLIP_betaMin(0.0);
fluidAlgorithm->setASFLIP_betaMax(0.0);
fluidAlgorithm->enableFBAR(true);
fluidAlgorithm->setFBAR_psi(0.85);
fluidAlgorithm->setFBAR_psi(0.95);
fluidAlgorithm->enableFBAR_fusedG2P2G(true);

debrisAlgorithm->enableASFLIP(false);
Expand All @@ -326,7 +326,7 @@ BodiesMPM::BodiesMPM(QWidget *parent)
debrisAlgorithm->setASFLIP_betaMax(0.0);
debrisAlgorithm->enableFBAR(false);
debrisAlgorithm->setFBAR_psi(0.0);
debrisAlgorithm->enableFBAR_fusedG2P2G(false);
debrisAlgorithm->enableFBAR_fusedG2P2G(true);

structureAlgorithm->enableASFLIP(false);
structureAlgorithm->setASFLIP_alpha(0.0);
Expand Down
2 changes: 1 addition & 1 deletion EVENTS/MPM/MPM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1756,7 +1756,7 @@ bool MPM::outputAppDataToJSON(QJsonObject &jsonObject) {
jsonObject["programFile"] = "osu_lwf"; // <- ClaymoreUW MPM executable filename on remote machine. Can be changed depending on compiled optimizations, versions, digital twin, etc.
jsonObject["maxRunTime"] = "120"; // <- Maximum run time for the simulation, timeout if exceeded
jsonObject["defaultMaxRunTime"] = "1440";
jsonObject["publicDirectory"] = "../mpm-public-ls6";
jsonObject["publicDirectory"] = "./"; // "../mpm-public-ls6"
jsonObject["inputFile"] = "scInput.json"; // <- Input file for the simulation
jsonObject["driverFile"] = "sc_driver"; // <- Python script to run the simulation

Expand Down
185 changes: 185 additions & 0 deletions EVENTS/MPMEvent/BasicMPMEvent.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/* *****************************************************************************
Copyright (c) 2016-2023, The Regents of the University of California (Regents).
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS
PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*************************************************************************** */

#include <BasicMPMEvent.h>
#include <QLabel>
#include <QString>
#include <QGridLayout>
#include <QJsonObject>
#include <QJsonArray>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <SC_FileEdit.h>
#include <SC_IntLineEdit.h>
#include <SimCenterPreferences.h>

BasicMPMEvent::BasicMPMEvent(QWidget *parent)
:SimCenterWidget(parent)
{
QString defaultExecutableFilename = "osu_lwf.exe";
QString defaultWorkflowFilename = "MPMEvent.py";
QString defaultSimulationFilename = "scene.json";
QString defaultResourceFilename = "wmdisp_hydro2sec_1200hz_smooth_14032023.csv";
QString defaultExecutable = SimCenterPreferences::getInstance()->getAppDir() + QDir::separator()
+ QString("applications") + QDir::separator() + QString("ClaymoreUW") + QDir::separator()
+ defaultExecutableFilename;
QString defaultWorkflowScript = pyScriptsPath() + QDir::separator()
+ defaultWorkflowFilename;
QString defaultSimulationScript = SimCenterPreferences::getInstance()->getAppDir() + QDir::separator()
+ QString("Examples") + QDir::separator()
+ QString("hdro-0002") + QDir::separator()
+ QString("src") + QDir::separator()
+ defaultSimulationFilename;
QString defaultResourceFile = SimCenterPreferences::getInstance()->getAppDir() + QDir::separator()
+ QString("Examples") + QDir::separator()
+ QString("WaveMaker") + QDir::separator()
+ defaultResourceFilename;
int defaultMaxMinutes = 1;

theBackendApp = new SC_FileEdit("executableFile");
theBackendScript = new SC_FileEdit("basicPyScript");
theSimulationScript = new SC_FileEdit("configFile");
theResourceFile = new SC_FileEdit("resourceFile");
theMaxMinutes = new SC_IntLineEdit("maxMinutes", defaultMaxMinutes);
theBackendApp->setToolTip("ClaymoreUW MPM executable file (*, *.exe) which launches the MPMEvent simulation script. This executable is launched from the workflow backend script in the SimCenter workflow.");
theBackendScript->setToolTip("Workflow backend script (*.py) which launches the MPMEvent simulation script. Handles the inputs and outputs for coupling ClaymoreUW MPM to the SimCenter workflow.");
theSimulationScript->setToolTip("ClaymoreUW MPM Scene File (*.json) which defines the MPMEvent numerical simulation program. This script is launched from the workflow backend script in the SimCenter workflow.");
theResourceFile->setToolTip("Resource file (*.csv) which defines the wave maker displacement for the MPMEvent numerical simulation program. This file is used to define the wave maker displacement for the MPMEvent numerical simulation program.");
theMaxMinutes->setToolTip("Maximum number of minutes to run the MPMEvent numerical simulation program.");
theBackendApp->setFilename(defaultExecutable);
theBackendScript->setFilename(defaultWorkflowScript);
theSimulationScript->setFilename(defaultSimulationScript);
theResourceFile->setFilename(defaultResourceFile);

QGridLayout *theLayout = new QGridLayout();
theLayout->addWidget(new QLabel("ClaymoreUW MPM Executable (*, *.exe)"),0,0);
theLayout->addWidget(theBackendApp, 0,1);
theLayout->addWidget(new QLabel("Workflow Backend Script (*.py)"),1,0);
theLayout->addWidget(theBackendScript, 1,1);
theLayout->addWidget(new QLabel("ClaymoreUW MPM Scene File (*.json)"),2,0);
theLayout->addWidget(theSimulationScript, 2,1);
theLayout->addWidget(new QLabel("Resource File (*.csv)"),3,0);
theLayout->addWidget(theResourceFile, 3,1);
theLayout->addWidget(new QLabel("Max Runtime Minutes"),4,0);
theLayout->addWidget(theMaxMinutes, 4,1);
theLayout->setRowStretch(5,1);
this->setLayout(theLayout);
}

BasicMPMEvent::~BasicMPMEvent()
{

}

bool
BasicMPMEvent::outputToJSON(QJsonObject &jsonObject)
{
theBackendApp->outputToJSON(jsonObject);
theBackendScript->outputToJSON(jsonObject);
theSimulationScript->outputToJSON(jsonObject);
theResourceFile->outputToJSON(jsonObject);
theMaxMinutes->outputToJSON(jsonObject);
return true;
}

bool
BasicMPMEvent::inputFromJSON(QJsonObject &jsonObject)
{
theBackendApp->inputFromJSON(jsonObject);
theBackendScript->inputFromJSON(jsonObject);
theSimulationScript->inputFromJSON(jsonObject);
theResourceFile->inputFromJSON(jsonObject);
theMaxMinutes->inputFromJSON(jsonObject);
return true;
}

QString BasicMPMEvent::pyScriptsPath()
{
QString backendAppDir = SimCenterPreferences::getInstance()->getAppDir() + QDir::separator()
+ QString("applications") + QDir::separator() + QString("createEVENT") + QDir::separator()
+ QString("MPMEvent");
return backendAppDir;
}

bool
BasicMPMEvent::copyFiles(QString &destDir)
{
QString defaultExecutableFilename = "osu_lwf.exe";
QString defaultWorkflowFilename = "MPMEvent.py";
QString defaultSimulationFilename = "scene.json";
QString defaultResourceFilename = "wmdisp_hydro2sec_1200hz_smooth_14032023.csv";
QString defaultExecutable = SimCenterPreferences::getInstance()->getAppDir() + QDir::separator()
+ QString("applications") + QDir::separator() + QString("ClaymoreUW") + QDir::separator()
+ defaultExecutableFilename;
QString defaultWorkflowScript = pyScriptsPath() + QDir::separator()
+ defaultWorkflowFilename;
QString defaultSimulationScript = SimCenterPreferences::getInstance()->getAppDir() + QDir::separator()
+ QString("Examples") + QDir::separator()
+ QString("hdro-0002") + QDir::separator()
+ QString("src") + QDir::separator()
+ defaultSimulationFilename;
QString defaultResourceFile = SimCenterPreferences::getInstance()->getAppDir() + QDir::separator()
+ QString("Examples") + QDir::separator()
+ QString("WaveMaker") + QDir::separator()
+ defaultResourceFilename;
if (theBackendApp->copyFile(destDir) != true) {
theBackendApp->setFilename(defaultExecutable);
if (theBackendApp->copyFile(destDir) != true) {
return false;
}
}
if (theBackendScript->copyFile(destDir) != true) {
theBackendScript->setFilename(defaultWorkflowScript);
if (theBackendScript->copyFile(destDir) != true) {
return false;
}
}
if (theSimulationScript->copyFile(destDir) != true) {
theSimulationScript->setFilename(defaultSimulationScript);
if (theSimulationScript->copyFile(destDir) != true) {
return false;
}
}
if (theResourceFile->copyFile(destDir) != true) {
theResourceFile->setFilename(defaultResourceFile);
if (theResourceFile->copyFile(destDir) != true) {
return false;
}
}
return true;
}

Loading

0 comments on commit aafdbfc

Please sign in to comment.