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

Update ClaymoreUW MPM, FOAMySees, and StochasticWaves front-ends #134

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
6 changes: 3 additions & 3 deletions EVENTS/HydroEventSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
//*********************************************************************************

enum class Event_b : bool {
GeoClawOpenFOAM_b = false,
WaveDigitalFlume_b = false,
GeoClawOpenFOAM_b = true,
WaveDigitalFlume_b = true,
CoupledDigitalTwin_b = true,
ClaymoreUW_b = true,
BasicClaymoreUW_b = true,
BasicClaymoreUW_b = false,
TaichiEvent_b = true,
CelerisTaichiEvent_b = true,
StochasticWaves_b = true,
Expand Down
93 changes: 41 additions & 52 deletions EVENTS/MPM/AlgorithmMPM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,20 @@ AlgorithmMPM::~AlgorithmMPM()

void AlgorithmMPM::clear(void)
{
// theOpenSeesPyScript->clear();
// theSurfaceFile->clear();
numericalMethod->setCurrentIndex(0);
particlesPerCell->clear();
useASFLIP->setChecked(true);
useFBAR->setChecked(true);
ASFLIP_alpha->clear();
ASFLIP_betaMin->clear();
ASFLIP_betaMax->clear();
FBAR_psi->clear();
useFBAR_fusedG2P2G->setChecked(true);
}

bool
AlgorithmMPM::outputToJSON(QJsonObject &jsonObject)
{
// theOpenSeesPyScript->outputToJSON(jsonObject);
// theSurfaceFile->outputToJSON(jsonObject);

// Note: ClaymoreUW will also need these defined in the JSON model/body object, not just the nested JSON partition/device object
// Future schema
QJsonObject algorithmObject;
Expand All @@ -278,70 +282,55 @@ AlgorithmMPM::outputToJSON(QJsonObject &jsonObject)
algorithmObject["ASFLIP_beta_max"] = ASFLIP_betaMax->text().toDouble();
algorithmObject["FBAR_psi"] = FBAR_psi->text().toDouble();
jsonObject["algorithm"] = algorithmObject;

// ClaymoreUW artifacts, Global algorithm settings. TODO: Deprecate
// jsonObject["type"] = numericalMethod->currentText();
// jsonObject["ppc"] = particlesPerCell->text().toDouble();
// jsonObject["use_ASFLIP"] = useASFLIP->isChecked();
// jsonObject["use_FBAR"] = useFBAR->isChecked();
// jsonObject["FBAR_fused_kernel"] = useFBAR_fusedG2P2G->isChecked(); // TODO: Rename
// jsonObject["alpha"] = ASFLIP_alpha->text().toDouble(); // TODO: Rename
// jsonObject["beta_min"] = ASFLIP_betaMin->text().toDouble(); // TODO: Rename
// jsonObject["beta_max"] = ASFLIP_betaMax->text().toDouble(); // TODO: Rename
// jsonObject["FBAR_ratio"] = FBAR_psi->text().toDouble(); // TODO: Rename?

return true;
}

bool
AlgorithmMPM::inputFromJSON(QJsonObject &jsonObject)
{

this->clear(); // Clear all bodies


if (jsonObject.contains("algorithm")) {
QJsonObject algorithmObject = jsonObject["algorithm"].toObject();
if (algorithmObject.contains("type")) {
QString type = algorithmObject["type"].toString();
int index = numericalMethod->findText(type);
if (index != -1) {
numericalMethod->setCurrentIndex(index);
}
}
if (algorithmObject.contains("ppc")) {
particlesPerCell->setText(QString::number(algorithmObject["ppc"].toDouble()));
}
if (algorithmObject.contains("use_ASFLIP")) {
useASFLIP->setChecked(algorithmObject["use_ASFLIP"].toBool());
}
if (algorithmObject.contains("use_FBAR")) {
useFBAR->setChecked(algorithmObject["use_FBAR"].toBool());
}
if (algorithmObject.contains("FBAR_fused_kernel")) {
useFBAR_fusedG2P2G->setChecked(algorithmObject["FBAR_fused_kernel"].toBool());
}
if (algorithmObject.contains("ASFLIP_alpha")) {
ASFLIP_alpha->setText(QString::number(algorithmObject["ASFLIP_alpha"].toDouble()));
}
if (algorithmObject.contains("ASFLIP_beta_min")) {
ASFLIP_betaMin->setText(QString::number(algorithmObject["ASFLIP_beta_min"].toDouble()));
}
if (algorithmObject.contains("ASFLIP_beta_max")) {
ASFLIP_betaMax->setText(QString::number(algorithmObject["ASFLIP_beta_max"].toDouble()));
}
if (algorithmObject.contains("FBAR_psi")) {
FBAR_psi->setText(QString::number(algorithmObject["FBAR_psi"].toDouble()));
if (jsonObject.contains("type")) {
QString type = jsonObject["type"].toString();
int index = numericalMethod->findText(type);
if (index != -1) {
numericalMethod->setCurrentIndex(index);
}
}
if (jsonObject.contains("ppc")) {
particlesPerCell->setText(QString::number(jsonObject["ppc"].toDouble()));
}
if (jsonObject.contains("use_ASFLIP")) {
useASFLIP->setChecked(jsonObject["use_ASFLIP"].toBool());
}
if (jsonObject.contains("use_FBAR")) {
useFBAR->setChecked(jsonObject["use_FBAR"].toBool());
}
if (jsonObject.contains("FBAR_fused_kernel")) {
useFBAR_fusedG2P2G->setChecked(jsonObject["FBAR_fused_kernel"].toBool());
}
if (jsonObject.contains("ASFLIP_alpha")) {
ASFLIP_alpha->setText(QString::number(jsonObject["ASFLIP_alpha"].toDouble()));
}
if (jsonObject.contains("ASFLIP_beta_min")) {
ASFLIP_betaMin->setText(QString::number(jsonObject["ASFLIP_beta_min"].toDouble()));
}
if (jsonObject.contains("ASFLIP_beta_max")) {
ASFLIP_betaMax->setText(QString::number(jsonObject["ASFLIP_beta_max"].toDouble()));
}
if (jsonObject.contains("FBAR_psi")) {
FBAR_psi->setText(QString::number(jsonObject["FBAR_psi"].toDouble()));
}

return true;
}

bool
AlgorithmMPM::copyFiles(QString &destDir)
{
// if (theOpenSeesPyScript->copyFile(destDir) != true)
// return false;
// return theSurfaceFile->copyFile(destDir);
Q_UNUSED(destDir);
return true;
}

Expand Down
109 changes: 77 additions & 32 deletions EVENTS/MPM/BodiesMPM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,24 +393,24 @@ BodiesMPM::~BodiesMPM()
void BodiesMPM::clear(void)
{
// Clear all bodies
fluidGeometries->clear();
fluidMaterial->clear();
fluidAlgorithm->clear();
fluidPartitions->clear();
debrisGeometries->clear();
debrisMaterial->clear();
debrisAlgorithm->clear();
debrisPartitions->clear();
structureGeometries->clear();
structureMaterial->clear();
structureAlgorithm->clear();
structurePartitions->clear();
for (int i=0; i<numAddedTabs; i++) {
addedGeometries[i]->clear();
addedMaterial[i]->clear();
addedAlgorithm[i]->clear();
addedPartitions[i]->clear();
}
// fluidGeometries->clear();
// fluidMaterial->clear();
// fluidAlgorithm->clear();
// fluidPartitions->clear();
// debrisGeometries->clear();
// debrisMaterial->clear();
// debrisAlgorithm->clear();
// debrisPartitions->clear();
// structureGeometries->clear();
// structureMaterial->clear();
// structureAlgorithm->clear();
// structurePartitions->clear();
// for (int i=0; i<numAddedTabs; i++) {
// addedGeometries[i]->clear();
// addedMaterial[i]->clear();
// addedAlgorithm[i]->clear();
// addedPartitions[i]->clear();
// }
}

bool
Expand Down Expand Up @@ -457,7 +457,7 @@ BodiesMPM::outputToJSON(QJsonObject &jsonObject)
}
bodyObject["track_particle_id"] = trackParticleIdsArray; // global
bodyObject["type"] = QJsonValue(QString("particles")); // global

bodyObject["name"] = QJsonValue(QString("fluid")); // global
bodiesArray.append(bodyObject);
}

Expand Down Expand Up @@ -500,7 +500,8 @@ BodiesMPM::outputToJSON(QJsonObject &jsonObject)
}
bodyObject["track_particle_id"] = trackParticleIdsArray; // global
bodyObject["type"] = QJsonValue(QString("particles")); // global

bodyObject["name"] = QJsonValue(QString("debris")); // global

// Place the new body JSON object into the main bodies array
bodiesArray.append(bodyObject);
}
Expand Down Expand Up @@ -546,7 +547,7 @@ BodiesMPM::outputToJSON(QJsonObject &jsonObject)
}
bodyObject["track_particle_id"] = trackParticleIdsArray; // global
bodyObject["type"] = QJsonValue(QString("particles")); // global

bodyObject["name"] = QJsonValue(QString("structure")); // global
bodiesArray.append(bodyObject);
}

Expand Down Expand Up @@ -599,6 +600,7 @@ BodiesMPM::outputToJSON(QJsonObject &jsonObject)
}
bodyObject["track_particle_id"] = trackParticleIdsArray; // global
bodyObject["type"] = QJsonValue(QString("particles")); // global
bodyObject["name"] = QJsonValue(QString("custom_") + QString::number(i+1)); // global

QJsonArray bodyVelocityArray; // Need to find a spot for a bodies global initial conditions in the schema
bodyVelocityArray.append(QJsonValue(0.0).toDouble());
Expand All @@ -620,14 +622,39 @@ BodiesMPM::outputToJSON(QJsonObject &jsonObject)
bool
BodiesMPM::inputFromJSON(QJsonObject &jsonObject)
{
// TODO: Implement inputFromJSON for all bodies
// theOpenSeesPyScript->inputFromJSON(jsonObject);
// theSurfaceFile->inputFromJSON(jsonObject);
// fluidGeometries->inputFromJSON(jsonObject);
// fluidMaterial->inputFromJSON(jsonObject);
// fluidAlgorithm->inputFromJSON(jsonObject);
// fluidPartitions->inputFromJSON(jsonObject);
// fluidOutputs->inputFromJSON(jsonObject);
this->clear(); // Clear all bodies

// Input all bodies
QJsonArray bodiesArray = jsonObject["bodies"].toArray();
for (int i=0; i<bodiesArray.size(); i++) {
QJsonObject bodyObject = bodiesArray[i].toObject();
QJsonObject materialObject = bodyObject["material"].toObject();
QJsonObject algorithmObject = bodyObject["algorithm"].toObject();
if (bodyObject["name"].toString() == "fluid") {
fluidGeometries->inputFromJSON(bodyObject);
fluidMaterial->inputFromJSON(materialObject);
fluidAlgorithm->inputFromJSON(algorithmObject);
fluidPartitions->inputFromJSON(bodyObject);
} else if (bodyObject["name"].toString() == "debris") {
debrisGeometries->inputFromJSON(bodyObject);
debrisMaterial->inputFromJSON(materialObject);
debrisAlgorithm->inputFromJSON(algorithmObject);
debrisPartitions->inputFromJSON(bodyObject);
} else if (bodyObject["name"].toString() == "structure") {
structureGeometries->inputFromJSON(bodyObject);
structureMaterial->inputFromJSON(materialObject);
structureAlgorithm->inputFromJSON(algorithmObject);
structurePartitions->inputFromJSON(bodyObject);
} else if (bodyObject["name"].toString().startsWith("custom_")) {
int customIdx = bodyObject["name"].toString().split("_")[1].toInt();
if (customIdx >= numReserveTabs) break;
addedGeometries[customIdx]->inputFromJSON(bodyObject);
addedMaterial[customIdx]->inputFromJSON(materialObject);
addedAlgorithm[customIdx]->inputFromJSON(algorithmObject);
addedPartitions[customIdx]->inputFromJSON(bodyObject);
}
}

// toggleFluid->setChecked(true); // Enable body by default if it exists in the JSON
// toggleDebris->setChecked(true); // Enable body by default if it exists in the JSON
// toggleStructure->setChecked(true); // Enable body by default if it exists in the JSON
Expand All @@ -637,9 +664,27 @@ BodiesMPM::inputFromJSON(QJsonObject &jsonObject)
bool
BodiesMPM::copyFiles(QString &destDir)
{
// if (theOpenSeesPyScript->copyFile(destDir) != true)
// return false;
// return theSurfaceFile->copyFile(destDir);
fluidGeometries->copyFiles(destDir);
fluidMaterial->copyFiles(destDir);
fluidAlgorithm->copyFiles(destDir);
fluidPartitions->copyFiles(destDir);

debrisGeometries->copyFiles(destDir);
debrisMaterial->copyFiles(destDir);
debrisAlgorithm->copyFiles(destDir);
debrisPartitions->copyFiles(destDir);

structureGeometries->copyFiles(destDir);
structureMaterial->copyFiles(destDir);
structureAlgorithm->copyFiles(destDir);
structurePartitions->copyFiles(destDir);

for (int i=0; i<numAddedTabs; i++) {
addedGeometries[i]->copyFiles(destDir);
addedMaterial[i]->copyFiles(destDir);
addedAlgorithm[i]->copyFiles(destDir);
addedPartitions[i]->copyFiles(destDir);
}

return true;
}
Expand Down
10 changes: 4 additions & 6 deletions EVENTS/MPM/BoundariesMPM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ BoundariesMPM::~BoundariesMPM()

void BoundariesMPM::clear(void)
{
for (int i=0; i<numAddedTabs; i++) {
if (i >= numReserveTabs) break;
addedBoundary[i]->clear();
}
// for (int i=0; i<numAddedTabs; i++) {
// if (i >= numReserveTabs) break;
// addedBoundary[i]->clear();
// }
}

// void BoundariesMPM::structDimensionsChangedSlot(void)
Expand Down Expand Up @@ -419,11 +419,9 @@ SC_DoubleLineEdit* BoundariesMPM::getSpacingZWidget(BoundaryMPM* theBoundary)
}



// bool BoundariesMPM::addBoundary(BoundaryMPM* theBoundary)



// bool
// BoundariesMPM::setBoundaryType(int typeIdx)
// {
Expand Down
Loading