Skip to content

Commit

Permalink
Making torque and omega optionally zero
Browse files Browse the repository at this point in the history
  • Loading branch information
llaniewski committed May 6, 2024
1 parent dd7b2a1 commit 98b2465
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
8 changes: 7 additions & 1 deletion src/Handlers/acRemoteForceInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int acRemoteForceInterface::ConnectRemoteForceInterface(std::string integrator_)
bool use_box = true;
attr = node.attribute("use_box");
if (attr) use_box = attr.as_bool();

if (use_box) {
lbRegion reg = solver->lattice->region;
double px = solver->lattice->px;
Expand All @@ -69,6 +69,12 @@ int acRemoteForceInterface::ConnectRemoteForceInterface(std::string integrator_)
pz + reg.dz - PART_MAR_BOX,
pz + reg.dz + reg.nz + PART_MAR_BOX);
}

attr = node.attribute("omega");
if (attr) solver->lattice->RFI_omega = attr.as_bool();
attr = node.attribute("torque");
if (attr) solver->lattice->RFI_torque = attr.as_bool();

MPI_Barrier(MPMD.local);
solver->lattice->RFI.Connect(MPMD.work,inter.work);

Expand Down
27 changes: 14 additions & 13 deletions src/Lattice.cu.Rt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ Lattice::Lattice(lbRegion _region, MPIInfo mpi_, int ns): zSet(ZONESETTINGS, ZON
container->particle_data_size = 0;
SC.balls = &RFI;
RFI.name = "TCLB";
RFI_omega = true;
RFI_torque = true;
}

/// Initialization of MPI buffors
Expand Down Expand Up @@ -398,14 +400,9 @@ void Lattice::CopyInParticles() {
CudaMalloc(&container->particle_data, RFI.mem_size());
}
container->particle_data_size = RFI.size();
for (size_t i=0; i<RFI.size(); i++){
RFI.RawData(i, RFI_DATA_FORCE+0) = 0;
RFI.RawData(i, RFI_DATA_FORCE+1) = 0;
RFI.RawData(i, RFI_DATA_FORCE+2) = 0;
RFI.RawData(i, RFI_DATA_MOMENT+0) = 0;
RFI.RawData(i, RFI_DATA_MOMENT+1) = 0;
RFI.RawData(i, RFI_DATA_MOMENT+2) = 0;
}
for (int j=0; j<6; j++) for (size_t i=0; i<RFI.size(); i++) RFI.RawData(i, RFI_DATA_FORCE+j) = 0;
if (!RFI_omega) for (int j=0; j<3; j++) for (size_t i=0; i<RFI.size(); i++) RFI.RawData(i, RFI_DATA_ANGVEL+j) = 0;

if (RFI.mem_size() > 0) {
CudaMemcpyAsync(container->particle_data, RFI.Particles(), RFI.mem_size(), CudaMemcpyHostToDevice, kernelStream);
}
Expand All @@ -422,12 +419,16 @@ void Lattice::CopyOutParticles() {
CudaStreamSynchronize(kernelStream);
DEBUG_PROF_PUSH("Testing particles for NaNs");
int nans = 0;
for (size_t i=0; i<RFI.size(); i++){
for (int j=0; j<3; j++){
if (! isfinite(RFI.RawData(i,RFI_DATA_FORCE+j))) {
nans++;
RFI.RawData(i,RFI_DATA_FORCE+j) = 0.0;
for (int j=0; j<6; j++) {
if (RFI_torque || (j<3)) {
for (size_t i=0; i<RFI.size(); i++){
if (! isfinite(RFI.RawData(i,RFI_DATA_FORCE+j))) {
nans++;
RFI.RawData(i,RFI_DATA_FORCE+j) = 0.0;
}
}
} else {
for (size_t i=0; i<RFI.size(); i++) RFI.RawData(i,RFI_DATA_FORCE+j) = 0.0;
}
}
if (nans > 0) notice("%d NANs in particle forces (overwritten with 0.0)\n", nans);
Expand Down
1 change: 1 addition & 0 deletions src/Lattice.h.Rt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public:
real_t px, py, pz;
MPIInfo mpi; ///< MPI information
rfi_t RFI;
bool RFI_omega, RFI_torque;
solidcontainer_t SC;
size_t particle_data_size_max;
char snapFileName[STRING_LEN];
Expand Down

0 comments on commit 98b2465

Please sign in to comment.