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

Enable displacement component in direction other than profile #123

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 );
pabloseleson marked this conversation as resolved.
Show resolved Hide resolved
}

// 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
Loading