Skip to content

Commit

Permalink
Incremental changes
Browse files Browse the repository at this point in the history
  • Loading branch information
psakievich committed Sep 8, 2023
1 parent b00743a commit 232ccd9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 29 deletions.
15 changes: 1 addition & 14 deletions src/Realm.C
Original file line number Diff line number Diff line change
Expand Up @@ -1841,12 +1841,6 @@ Realm::update_geometry_due_to_mesh_motion()
if (does_mesh_move()) {
if (aeroModels_->is_active()) {
aeroModels_->update_displacements(get_current_time());

if (aeroModels_->has_fsi()) {
auto part_vec = aeroModels_->fsi_parts();
for (auto* target_part : part_vec)
set_current_coordinates(target_part);
}
}

if (solutionOptions_->externalMeshDeformation_) {
Expand Down Expand Up @@ -2562,7 +2556,7 @@ Realm::set_current_coordinates(stk::mesh::Part* targetPart)
VectorFieldType* displacement = meta_data().get_field<VectorFieldType>(
stk::topology::NODE_RANK, "mesh_displacement");

currentCoords->sync_to_host();
currentCoords->clear_sync_state();
displacement->sync_to_host();
modelCoords->sync_to_host();

Expand Down Expand Up @@ -3474,17 +3468,10 @@ Realm::populate_restart(double& timeStepNm1, int& timeStepCount)
meshMotionAlg_->restart_reinit(foundRestartTime);

if (aeroModels_->has_fsi()) {
// TODO(psakiev) we should move this inside the function and compute
// current coordinates there
NaluEnv::self().naluOutputP0()
<< "Aero models - Update displacements and set current coordinates"
<< std::endl;
aeroModels_->update_displacements(restartTime);

auto part_vec = aeroModels_->fsi_parts();
for (auto* target_part : part_vec) {
set_current_coordinates(target_part);
}
}

compute_geometry();
Expand Down
40 changes: 25 additions & 15 deletions src/aero/fsi/FSIturbine.C
Original file line number Diff line number Diff line change
Expand Up @@ -1366,13 +1366,16 @@ fsiTurbine::mapDisplacements(double time)
auto& meta = bulk_->mesh_meta_data();
const VectorFieldType* modelCoords =
meta.get_field<VectorFieldType>(stk::topology::NODE_RANK, "coordinates");
VectorFieldType* curCoords =
meta.get_field<VectorFieldType>(stk::topology::NODE_RANK, "current_coordinates");
VectorFieldType* displacement = meta.get_field<VectorFieldType>(
stk::topology::NODE_RANK, "mesh_displacement");

VectorFieldType* meshVelocity =
meta.get_field<VectorFieldType>(stk::topology::NODE_RANK, "mesh_velocity");

modelCoords->sync_to_host();
curCoords->sync_to_host();
displacement->sync_to_host();
meshVelocity->sync_to_host();
dispMap_->sync_to_host();
Expand All @@ -1395,7 +1398,7 @@ fsiTurbine::mapDisplacements(double time)
for (auto b : bkts) {
for (size_t in = 0; in < b->size(); in++) {
auto node = (*b)[in];
auto oldxyz = vector_from_field(*modelCoords, node);
auto nodePosition = vector_from_field(*modelCoords, node);
int* dispMapNode = stk::mesh::field_data(*dispMap_, node);
const int iN = 6 * (*dispMapNode);
const int iNp1 = 6 * (*dispMapNode + 1);
Expand All @@ -1414,9 +1417,9 @@ fsiTurbine::mapDisplacements(double time)
twrStartDisp, twrEndDisp, *dispMapInterpNode);

// Now transfer the interpolated displacement to the CFD mesh node
vector_to_field(
aero::compute_translational_displacements(deflection, refPos, oldxyz),
*displacement, node);
auto dispVec = aero::compute_translational_displacements(deflection, refPos, nodePosition);
vector_to_field(dispVec, *displacement, node);
vector_to_field(dispVec + nodePosition, *curCoords, node);
}
}

Expand Down Expand Up @@ -1493,6 +1496,7 @@ fsiTurbine::mapDisplacements(double time)
auto ramp_disp = aero::compute_translational_displacements(
interpDisp, refPos, nodePosition, hubBasedDef, deflectionRamp);
vector_to_field(ramp_disp, *displacement, node);
vector_to_field(ramp_disp + nodePosition, *curCoords, node);

auto bldStartVel = aero::SixDOF(&(brFSIdata_.bld_vel[iN]));
auto bldEndVel = aero::SixDOF(&(brFSIdata_.bld_vel[iNp1]));
Expand Down Expand Up @@ -1521,17 +1525,16 @@ fsiTurbine::mapDisplacements(double time)
for (size_t in = 0; in < b->size(); in++) {
auto node = (*b)[in];

auto oldxyz = vector_from_field(*modelCoords, node);
auto nodePosition = vector_from_field(*modelCoords, node);
// Now transfer the displacement to the CFD mesh node
vector_to_field(
aero::compute_translational_displacements(
hubDeflection, hubPos, oldxyz),
*displacement, node);
auto dispVec = aero::compute_translational_displacements(hubDeflection, hubPos, nodePosition);
vector_to_field(dispVec, *displacement, node);
vector_to_field(dispVec + nodePosition, *curCoords, node);

// Now transfer the translational and rotational velocity to an equivalent
// translational velocity on the CFD mesh node
vector_to_field(
aero::compute_mesh_velocity(hubVel, hubDeflection, hubPos, oldxyz),
aero::compute_mesh_velocity(hubVel, hubDeflection, hubPos, nodePosition),
*meshVelocity, node);
}
}
Expand All @@ -1542,25 +1545,32 @@ fsiTurbine::mapDisplacements(double time)
for (auto b : nacbkts) {
for (size_t in = 0; in < b->size(); in++) {
auto node = (*b)[in];
auto oldxyz = vector_from_field(*modelCoords, node);
auto nodePosition = vector_from_field(*modelCoords, node);
const aero::SixDOF refPos(brFSIdata_.nac_ref_pos.data());
const aero::SixDOF deflection(brFSIdata_.nac_def.data());

// Now transfer the displacement to the CFD mesh node
vector_to_field(
aero::compute_translational_displacements(deflection, refPos, oldxyz),
*displacement, node);
auto dispVec =aero::compute_translational_displacements(deflection, refPos, nodePosition);
vector_to_field(dispVec,*displacement, node);
vector_to_field(dispVec+nodePosition,*curCoords, node);

// Now transfer the translational and rotational velocity to an equivalent
// translational velocity on the CFD mesh node
auto mVel = vector_from_field(*meshVelocity, node);
const aero::SixDOF vel(brFSIdata_.nac_vel.data());

mVel = aero::compute_mesh_velocity(vel, deflection, refPos, oldxyz);
mVel = aero::compute_mesh_velocity(vel, deflection, refPos, nodePosition);
}
}
curCoords->modify_on_host();
displacement->modify_on_host();
meshVelocity->modify_on_host();
deflectionRamp_->modify_on_host();
// ideally these should occur on device so lets copy them there for now
// mesh motion computes these on device so we can remove some unnecessary syncs
curCoords->sync_to_device();
displacement->sync_to_device();
meshVelocity->sync_to_device();
}

//! Compose Wiener-Milenkovic parameters 'p' and 'q' into 'pPlusq'. If a
Expand Down

0 comments on commit 232ccd9

Please sign in to comment.