Skip to content

Commit

Permalink
Changes for time-dependent thermal deformation
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloseleson committed Dec 12, 2023
1 parent 414b2c6 commit a01ceba
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
16 changes: 13 additions & 3 deletions examples/thermal_deformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,25 @@ int main( int argc, char* argv[] )
// Define particle initialization.
auto x = particles->sliceReferencePosition();
auto u = particles->sliceDisplacement();
auto f = particles->sliceForce();
auto v = particles->sliceVelocity();
auto rho = particles->sliceDensity();
// auto temp = particles->sliceTemperature();

// Domain to apply b.c.
CabanaPD::RegionBoundary domain1( low_corner[0], high_corner[0],
low_corner[1], high_corner[1],
low_corner[2], high_corner[2] );
std::vector<CabanaPD::RegionBoundary> domain = { domain1 };

double b0 = 0.0;
auto bc =
createBoundaryCondition( CabanaPD::ForceCrackBranchBCTag{},
exec_space{}, *particles, domain, b0 );

auto init_functor = KOKKOS_LAMBDA( const int pid )
{
// temp( pid ) = 5000 * x( pid, 1 );
// temp( pid ) = 5000 * x( pid, 1 ) * t_final;
rho( pid ) = rho0;
};
particles->updateParticles( exec_space{}, init_functor );
Expand All @@ -90,8 +102,6 @@ int main( int argc, char* argv[] )
cabana_pd->init_force();
cabana_pd->run();

x = particles->sliceReferencePosition();
u = particles->sliceDisplacement();
double num_cell_x = inputs.num_cells[0];
auto profile = Kokkos::View<double* [2], memory_space>(
Kokkos::ViewAllocateWithoutInitializing( "displacement_profile" ),
Expand Down
23 changes: 14 additions & 9 deletions src/CabanaPD_Boundary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ struct BoundaryCondition<BCIndexSpace, ForceValueBCTag>
Kokkos::parallel_for(
"CabanaPD::BC::apply", policy, KOKKOS_LAMBDA( const int b ) {
auto pid = index_space( b );
// This is specifically for the thermal deformation problem
temp( pid ) = 5000 * x( pid, 1 ) * t;
std::cout << "1: temp(" << pid << ")=" << temp( pid )
<< std::endl;
} );
}
};
Expand All @@ -196,16 +199,17 @@ struct BoundaryCondition<BCIndexSpace, ForceUpdateBCTag>
template <class ExecSpace, class ParticleType>
void apply( ExecSpace, ParticleType& particles, double t )
{
auto f = particles.sliceForce();
auto temp = particles.sliceTemperature();
auto index_space = _index_space._view;
Kokkos::RangePolicy<ExecSpace> policy( 0, index_space.size() );
auto value = _value;
Kokkos::parallel_for(
"CabanaPD::BC::apply", policy, KOKKOS_LAMBDA( const int b ) {
auto pid = index_space( b );
temp( pid ) = 5000 * x( pid, 1 ) * t;
// for ( int d = 0; d < 3; d++ )
// f( pid, d ) += value;
// This is specifically for the thermal deformation problem
temp( pid ) += 5000 * x( pid, 1 ) * t;
std::cout << "2: temp(" << pid << ")=" << temp( pid )
<< std::endl;
} );
}
};
Expand All @@ -230,19 +234,20 @@ struct BoundaryCondition<BCIndexSpace, ForceCrackBranchBCTag>
}

template <class ExecSpace, class ParticleType>
void apply( ExecSpace, ParticleType& particles, double )
void apply( ExecSpace, ParticleType& particles, double t )
{
auto f = particles.sliceForce();
auto temp = particles.sliceTemperature();
auto x = particles.sliceReferencePosition();
auto index_space = _index_space._view;
Kokkos::RangePolicy<ExecSpace> policy( 0, index_space.size() );
auto value = _value;
Kokkos::parallel_for(
"CabanaPD::BC::apply", policy, KOKKOS_LAMBDA( const int b ) {
auto pid = index_space( b );
// This is specifically for the crack branching.
auto sign = std::abs( x( pid, 1 ) ) / x( pid, 1 );
f( pid, 1 ) += value * sign;
// This is specifically for the thermal deformation problem
temp( pid ) += 5000 * x( pid, 1 ) * t;
std::cout << "3: temp(" << pid << ")=" << temp( pid )
<< std::endl;
} );
}
};
Expand Down

0 comments on commit a01ceba

Please sign in to comment.