Skip to content

Commit

Permalink
small modifs
Browse files Browse the repository at this point in the history
Former-commit-id: c78fbdf
  • Loading branch information
PierreLaurentinCS committed Dec 19, 2023
1 parent 0740317 commit 2f14102
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 83 deletions.
150 changes: 75 additions & 75 deletions include/core/mobility_cahn_hilliard_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,23 +215,23 @@ class MobilityCahnHilliardModelQuartic : public MobilityCahnHilliardModel
double
value(const std::map<field, double> &fields_value) override
{
// const double &phase_order_cahn_hilliard =
// fields_value.at(field::phase_order_cahn_hilliard);
const double &phase_order_cahn_hilliard_filtered =
fields_value.at(field::phase_order_cahn_hilliard_filtered);
// if (std::abs(phase_order_cahn_hilliard) > 1)
// return 0.0;
// else
// return mobility_cahn_hilliard_constant *
// (1 - phase_order_cahn_hilliard * phase_order_cahn_hilliard) *
// (1 - phase_order_cahn_hilliard * phase_order_cahn_hilliard);
const double &phase_order_cahn_hilliard =
fields_value.at(field::phase_order_cahn_hilliard);
// const double &phase_order_cahn_hilliard_filtered =
// fields_value.at(field::phase_order_cahn_hilliard_filtered);
if (std::abs(phase_order_cahn_hilliard) > 1)
return 0.0;
else
return mobility_cahn_hilliard_constant *
(1 - phase_order_cahn_hilliard * phase_order_cahn_hilliard) *
(1 - phase_order_cahn_hilliard * phase_order_cahn_hilliard);
//std::cout<<"phase order value in filter = "<<phase_order_cahn_hilliard_filtered<<std::endl;
if (std::abs(phase_order_cahn_hilliard_filtered) > 1)
return 0.0;
else
return mobility_cahn_hilliard_constant *
(1 - phase_order_cahn_hilliard_filtered * phase_order_cahn_hilliard_filtered) *
(1 - phase_order_cahn_hilliard_filtered * phase_order_cahn_hilliard_filtered);
// if (std::abs(phase_order_cahn_hilliard_filtered) > 1)
// return 0.0;
// else
// return mobility_cahn_hilliard_constant *
// (1 - phase_order_cahn_hilliard_filtered * phase_order_cahn_hilliard_filtered) *
// (1 - phase_order_cahn_hilliard_filtered * phase_order_cahn_hilliard_filtered);
}

/**
Expand All @@ -243,32 +243,32 @@ class MobilityCahnHilliardModelQuartic : public MobilityCahnHilliardModel
vector_value(const std::map<field, std::vector<double>> &field_vectors,
std::vector<double> &property_vector) override
{
// const std::vector<double> &phase_order_cahn_hilliard =
// field_vectors.at(field::phase_order_cahn_hilliard);
// for (unsigned int i = 0; i < property_vector.size(); ++i)
// {
// if (std::abs(phase_order_cahn_hilliard[i]) > 1)
// property_vector[i] = 0.0;
// else
// property_vector[i] =
// mobility_cahn_hilliard_constant *
// (1 - phase_order_cahn_hilliard[i] * phase_order_cahn_hilliard[i]) *
// (1 - phase_order_cahn_hilliard[i] * phase_order_cahn_hilliard[i]);
// }

const std::vector<double> &phase_order_cahn_hilliard_filtered =
field_vectors.at(field::phase_order_cahn_hilliard_filtered);
for (unsigned int i = 0; i < property_vector.size(); ++i)
const std::vector<double> &phase_order_cahn_hilliard =
field_vectors.at(field::phase_order_cahn_hilliard);
for (unsigned int i = 0; i < property_vector.size(); ++i)
{
//std::cout<<"phase order value in filter = "<<phase_order_cahn_hilliard_filtered[i]<<std::endl;
if (std::abs(phase_order_cahn_hilliard_filtered[i]) > 1)
property_vector[i] = 0.0;
else
property_vector[i] =
mobility_cahn_hilliard_constant *
(1 - phase_order_cahn_hilliard_filtered[i] * phase_order_cahn_hilliard_filtered[i]) *
(1 - phase_order_cahn_hilliard_filtered[i] * phase_order_cahn_hilliard_filtered[i]);
if (std::abs(phase_order_cahn_hilliard[i]) > 1)
property_vector[i] = 0.0;
else
property_vector[i] =
mobility_cahn_hilliard_constant *
(1 - phase_order_cahn_hilliard[i] * phase_order_cahn_hilliard[i]) *
(1 - phase_order_cahn_hilliard[i] * phase_order_cahn_hilliard[i]);
}

// const std::vector<double> &phase_order_cahn_hilliard_filtered =
// field_vectors.at(field::phase_order_cahn_hilliard_filtered);
// for (unsigned int i = 0; i < property_vector.size(); ++i)
// {
// //std::cout<<"phase order value in filter = "<<phase_order_cahn_hilliard_filtered[i]<<std::endl;
// if (std::abs(phase_order_cahn_hilliard_filtered[i]) > 1)
// property_vector[i] = 0.0;
// else
// property_vector[i] =
// mobility_cahn_hilliard_constant *
// (1 - phase_order_cahn_hilliard_filtered[i] * phase_order_cahn_hilliard_filtered[i]) *
// (1 - phase_order_cahn_hilliard_filtered[i] * phase_order_cahn_hilliard_filtered[i]);
// }
}

/**
Expand All @@ -282,22 +282,22 @@ class MobilityCahnHilliardModelQuartic : public MobilityCahnHilliardModel
double
jacobian(const std::map<field, double> &fields_value, field /*id*/) override
{
// const double &phase_order_cahn_hilliard =
// fields_value.at(field::phase_order_cahn_hilliard);
// if (std::abs(phase_order_cahn_hilliard) > 1)
// return 0.0;
// else
// return -4 * phase_order_cahn_hilliard * mobility_cahn_hilliard_constant *
// (1 - phase_order_cahn_hilliard * phase_order_cahn_hilliard);

const double &phase_order_cahn_hilliard_filtered =
fields_value.at(field::phase_order_cahn_hilliard_filtered);
//std::cout<<"phase order value in filter = "<<phase_order_cahn_hilliard_filtered<<std::endl;
if (std::abs(phase_order_cahn_hilliard_filtered) > 1)
return 0.0;
else
return -4 * phase_order_cahn_hilliard_filtered * mobility_cahn_hilliard_constant *
(1 - phase_order_cahn_hilliard_filtered * phase_order_cahn_hilliard_filtered);
const double &phase_order_cahn_hilliard =
fields_value.at(field::phase_order_cahn_hilliard);
if (std::abs(phase_order_cahn_hilliard) > 1)
return 0.0;
else
return -4 * phase_order_cahn_hilliard * mobility_cahn_hilliard_constant *
(1 - phase_order_cahn_hilliard * phase_order_cahn_hilliard);

// const double &phase_order_cahn_hilliard_filtered =
// fields_value.at(field::phase_order_cahn_hilliard_filtered);
// //std::cout<<"phase order value in filter = "<<phase_order_cahn_hilliard_filtered<<std::endl;
// if (std::abs(phase_order_cahn_hilliard_filtered) > 1)
// return 0.0;
// else
// return -4 * phase_order_cahn_hilliard_filtered * mobility_cahn_hilliard_constant *
// (1 - phase_order_cahn_hilliard_filtered * phase_order_cahn_hilliard_filtered);
}

/**
Expand All @@ -312,25 +312,25 @@ class MobilityCahnHilliardModelQuartic : public MobilityCahnHilliardModel
const field /*id*/,
std::vector<double> &jacobian_vector) override
{
// const std::vector<double> &phase_order_cahn_hilliard =
// field_vectors.at(field::phase_order_cahn_hilliard);
// for (unsigned int i = 0; i < jacobian_vector.size(); ++i)
// if (std::abs(phase_order_cahn_hilliard[i]) > 1)
// jacobian_vector[i] = 0.0;
// else
// jacobian_vector[i] =
// -mobility_cahn_hilliard_constant * 4 * phase_order_cahn_hilliard[i] *
// (1 - phase_order_cahn_hilliard[i] * phase_order_cahn_hilliard[i]);

const std::vector<double> &phase_order_cahn_hilliard_filtered =
field_vectors.at(field::phase_order_cahn_hilliard_filtered);
for (unsigned int i = 0; i < jacobian_vector.size(); ++i)
if (std::abs(phase_order_cahn_hilliard_filtered[i]) > 1)
jacobian_vector[i] = 0.0;
else
jacobian_vector[i] =
-mobility_cahn_hilliard_constant * 4 * phase_order_cahn_hilliard_filtered[i] *
(1 - phase_order_cahn_hilliard_filtered[i] * phase_order_cahn_hilliard_filtered[i]);
const std::vector<double> &phase_order_cahn_hilliard =
field_vectors.at(field::phase_order_cahn_hilliard);
for (unsigned int i = 0; i < jacobian_vector.size(); ++i)
if (std::abs(phase_order_cahn_hilliard[i]) > 1)
jacobian_vector[i] = 0.0;
else
jacobian_vector[i] =
-mobility_cahn_hilliard_constant * 4 * phase_order_cahn_hilliard[i] *
(1 - phase_order_cahn_hilliard[i] * phase_order_cahn_hilliard[i]);

// const std::vector<double> &phase_order_cahn_hilliard_filtered =
// field_vectors.at(field::phase_order_cahn_hilliard_filtered);
// for (unsigned int i = 0; i < jacobian_vector.size(); ++i)
// if (std::abs(phase_order_cahn_hilliard_filtered[i]) > 1)
// jacobian_vector[i] = 0.0;
// else
// jacobian_vector[i] =
// -mobility_cahn_hilliard_constant * 4 * phase_order_cahn_hilliard_filtered[i] *
// (1 - phase_order_cahn_hilliard_filtered[i] * phase_order_cahn_hilliard_filtered[i]);
}

private:
Expand Down
16 changes: 8 additions & 8 deletions source/solvers/navier_stokes_cahn_hilliard_assemblers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ GLSNavierStokesCahnHilliardAssemblerCore<dim>::assemble_matrix(

const double potential_value =
scratch_data.chemical_potential_cahn_hilliard_values[q];
const Tensor<1, dim> phase_order_gradient =
scratch_data.phase_order_cahn_hilliard_gradients[q];
// const Tensor<1, dim> phase_order_gradient =
// scratch_data.filtered_phase_order_cahn_hilliard_gradients[q];
// const Tensor<1, dim> phase_order_gradient =
// scratch_data.phase_order_cahn_hilliard_gradients[q];
const Tensor<1, dim> phase_order_gradient =
scratch_data.filtered_phase_order_cahn_hilliard_gradients[q];

double mobility = scratch_data.mobility_cahn_hilliard[q];
// std::cout<<"mobility via chns assembler = "<<mobility<<std::endl;
Expand Down Expand Up @@ -249,10 +249,10 @@ GLSNavierStokesCahnHilliardAssemblerCore<dim>::assemble_rhs(
scratch_data.chemical_potential_cahn_hilliard_gradients[q];
const double potential_value =
scratch_data.chemical_potential_cahn_hilliard_values[q];
const Tensor<1, dim> phase_order_gradient =
scratch_data.phase_order_cahn_hilliard_gradients[q];
// const Tensor<1, dim> phase_order_gradient =
// scratch_data.filtered_phase_order_cahn_hilliard_gradients[q];
// const Tensor<1, dim> phase_order_gradient =
// scratch_data.phase_order_cahn_hilliard_gradients[q];
const Tensor<1, dim> phase_order_gradient =
scratch_data.filtered_phase_order_cahn_hilliard_gradients[q];

// Gather into local variables the relevant fields for velocity
const Tensor<1, dim> velocity = scratch_data.velocity_values[q];
Expand Down

0 comments on commit 2f14102

Please sign in to comment.