Skip to content

Commit

Permalink
Merge pull request #123 from streeve/profile_dim
Browse files Browse the repository at this point in the history
Enable displacement component in direction other than profile
  • Loading branch information
streeve authored Aug 8, 2024
2 parents 2741d37 + d7f10e0 commit 95bc551
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
6 changes: 3 additions & 3 deletions examples/mechanics/elastic_wave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ void elasticWaveExample( const std::string filename )
// ====================================================
// Outputs
// ====================================================
// Output displacement along the x-axis
createDisplacementProfile( MPI_COMM_WORLD, num_cells[0], 0,
"displacement_profile.txt", *particles );
// Output x-displacement along the x-axis
createDisplacementProfile( MPI_COMM_WORLD, "displacement_profile.txt",
*particles, num_cells[0], 0 );
}

// Initialize MPI+Kokkos.
Expand Down
26 changes: 19 additions & 7 deletions examples/thermomechanics/thermal_deformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,25 @@ void thermalDeformationExample( const std::string filename )
// ====================================================
// Outputs
// ====================================================
// Output displacement along the x-axis
createDisplacementProfile( MPI_COMM_WORLD, num_cells[0], 0,
"xdisplacement_profile.txt", *particles );

// Output displacement along the y-axis
createDisplacementProfile( MPI_COMM_WORLD, num_cells[1], 1,
"ydisplacement_profile.txt", *particles );
// Output y-displacement along the x-axis
createDisplacementProfile( MPI_COMM_WORLD,
"ydisplacement_xaxis_profile.txt", *particles,
num_cells[0], 0, 1 );

// Output y-displacement along the y-axis
createDisplacementProfile( MPI_COMM_WORLD,
"ydisplacement_yaxis_profile.txt", *particles,
num_cells[1], 1, 1 );

// Output displacement magnitude along the x-axis
createDisplacementMagnitudeProfile(
MPI_COMM_WORLD, "displacement_magnitude_xaxis_profile.txt", *particles,
num_cells[0], 0 );

// Output displacement magnitude along the y-axis
createDisplacementMagnitudeProfile(
MPI_COMM_WORLD, "displacement_magnitude_yaxis_profile.txt", *particles,
num_cells[1], 1 );
}

// Initialize MPI+Kokkos.
Expand Down
20 changes: 12 additions & 8 deletions src/CabanaPD_DisplacementProfile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,28 @@ void createOutputProfile( MPI_Comm comm, const int num_cell,
}

template <typename ParticleType>
void createDisplacementProfile( MPI_Comm comm, const int num_cell,
const int profile_dim, std::string file_name,
ParticleType particles )
void createDisplacementProfile( MPI_Comm comm, std::string file_name,
ParticleType particles, const int num_cell,
const int profile_dim,
int displacement_dim = -1 )
{
if ( displacement_dim == -1 )
displacement_dim = profile_dim;

auto u = particles.sliceDisplacement();
auto value = KOKKOS_LAMBDA( const int pid )
{
return u( pid, profile_dim );
return u( pid, displacement_dim );
};
createOutputProfile( comm, num_cell, profile_dim, file_name, particles,
value );
}

template <typename ParticleType>
void createDisplacementMagnitudeProfile( MPI_Comm comm, const int num_cell,
const int profile_dim,
std::string file_name,
ParticleType particles )
void createDisplacementMagnitudeProfile( MPI_Comm comm, std::string file_name,
ParticleType particles,
const int num_cell,
const int profile_dim )
{
auto u = particles.sliceDisplacement();
auto magnitude = KOKKOS_LAMBDA( const int pid )
Expand Down

0 comments on commit 95bc551

Please sign in to comment.