From 3e76d7ea541dcf12049aeb7555ad51dc14f8f63e Mon Sep 17 00:00:00 2001 From: Rene Gassmoeller Date: Tue, 21 Nov 2017 18:16:49 -0700 Subject: [PATCH] Address comments --- include/aspect/free_surface.h | 9 ++++-- include/aspect/melt.h | 14 --------- include/aspect/newton.h | 12 ++++---- .../aspect/simulator/assemblers/advection.h | 6 ---- .../aspect/simulator/assemblers/interface.h | 22 +++++--------- include/aspect/simulator/assemblers/stokes.h | 18 ----------- include/aspect/simulator_access.h | 4 +-- source/simulator/assemblers/interface.cc | 30 ++++++++++++++++++- source/simulator/assemblers/newton_stokes.cc | 1 + source/simulator/assembly.cc | 2 +- source/simulator/entropy_viscosity.cc | 6 ++-- source/simulator/melt.cc | 1 + source/simulator/simulator_access.cc | 1 + 13 files changed, 59 insertions(+), 67 deletions(-) diff --git a/include/aspect/free_surface.h b/include/aspect/free_surface.h index 5b5e45599d4..35d9379cd1c 100644 --- a/include/aspect/free_surface.h +++ b/include/aspect/free_surface.h @@ -41,8 +41,13 @@ namespace aspect class ApplyStabilization: public Assemblers::Interface, public SimulatorAccess { - void execute (internal::Assembly::Scratch::ScratchBase &scratch, - internal::Assembly::CopyData::CopyDataBase &data) const; + public: + virtual ~ApplyStabilization () {}; + + virtual + void + execute (internal::Assembly::Scratch::ScratchBase &scratch, + internal::Assembly::CopyData::CopyDataBase &data) const; }; } diff --git a/include/aspect/melt.h b/include/aspect/melt.h index 146f4c961ec..8a7613f086c 100644 --- a/include/aspect/melt.h +++ b/include/aspect/melt.h @@ -146,8 +146,6 @@ namespace aspect public SimulatorAccess { public: - virtual ~MeltInterface () {}; - /** * Attach melt outputs. Since most melt assemblers require the * melt material model properties they are created in this base class @@ -166,8 +164,6 @@ namespace aspect class MeltStokesPreconditioner : public MeltInterface { public: - virtual ~MeltStokesPreconditioner () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, @@ -182,8 +178,6 @@ namespace aspect class MeltStokesSystem : public MeltInterface { public: - virtual ~MeltStokesSystem () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, @@ -200,8 +194,6 @@ namespace aspect class MeltStokesSystemBoundary : public MeltInterface { public: - virtual ~MeltStokesSystemBoundary () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, @@ -216,8 +208,6 @@ namespace aspect class MeltAdvectionSystem : public MeltInterface { public: - virtual ~MeltAdvectionSystem () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, @@ -241,8 +231,6 @@ namespace aspect class MeltPressureRHSCompatibilityModification : public MeltInterface { public: - virtual ~MeltPressureRHSCompatibilityModification () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, @@ -256,8 +244,6 @@ namespace aspect class MeltBoundaryTraction : public MeltInterface { public: - virtual ~MeltBoundaryTraction () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, diff --git a/include/aspect/newton.h b/include/aspect/newton.h index 6f5e625ee9b..55ea7c52e7f 100644 --- a/include/aspect/newton.h +++ b/include/aspect/newton.h @@ -140,7 +140,7 @@ namespace aspect class NewtonStokesPreconditioner : public NewtonInterface { public: - virtual ~NewtonStokesPreconditioner () {}; + virtual ~NewtonStokesPreconditioner () {} void execute (internal::Assembly::Scratch::ScratchBase &scratch, @@ -155,7 +155,7 @@ namespace aspect class NewtonStokesIncompressibleTerms : public NewtonInterface { public: - virtual ~NewtonStokesIncompressibleTerms () {}; + virtual ~NewtonStokesIncompressibleTerms () {} void execute (internal::Assembly::Scratch::ScratchBase &scratch, @@ -171,7 +171,7 @@ namespace aspect public SimulatorAccess { public: - virtual ~NewtonStokesCompressibleStrainRateViscosityTerm () {}; + virtual ~NewtonStokesCompressibleStrainRateViscosityTerm () {} virtual void @@ -190,7 +190,7 @@ namespace aspect public SimulatorAccess { public: - virtual ~NewtonStokesReferenceDensityCompressibilityTerm () {}; + virtual ~NewtonStokesReferenceDensityCompressibilityTerm () {} virtual void @@ -211,7 +211,7 @@ namespace aspect public SimulatorAccess { public: - virtual ~NewtonStokesImplicitReferenceDensityCompressibilityTerm () {}; + virtual ~NewtonStokesImplicitReferenceDensityCompressibilityTerm () {} virtual void @@ -230,7 +230,7 @@ namespace aspect public SimulatorAccess { public: - virtual ~NewtonStokesIsothermalCompressionTerm () {}; + virtual ~NewtonStokesIsothermalCompressionTerm () {} virtual void diff --git a/include/aspect/simulator/assemblers/advection.h b/include/aspect/simulator/assemblers/advection.h index 644d732daec..910096a4a6c 100644 --- a/include/aspect/simulator/assemblers/advection.h +++ b/include/aspect/simulator/assemblers/advection.h @@ -38,8 +38,6 @@ namespace aspect public SimulatorAccess { public: - virtual ~AdvectionSystem () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, @@ -59,8 +57,6 @@ namespace aspect public SimulatorAccess { public: - virtual ~AdvectionSystemBoundaryFace () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, @@ -76,8 +72,6 @@ namespace aspect public SimulatorAccess { public: - virtual ~AdvectionSystemInteriorFace () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, diff --git a/include/aspect/simulator/assemblers/interface.h b/include/aspect/simulator/assemblers/interface.h index de6fca178d0..0c0a82eae5a 100644 --- a/include/aspect/simulator/assemblers/interface.h +++ b/include/aspect/simulator/assemblers/interface.h @@ -62,13 +62,13 @@ namespace aspect : cell(), face_number(numbers::invalid_unsigned_int) - {}; + {} ScratchBase(const ScratchBase &scratch) : cell(scratch.cell), face_number(scratch.face_number) - {}; + {} virtual ~ScratchBase () {}; @@ -333,8 +333,6 @@ namespace aspect template struct CopyDataBase { - CopyDataBase() {}; - virtual ~CopyDataBase () {}; }; @@ -486,7 +484,7 @@ namespace aspect class Interface { public: - virtual ~Interface () {} + virtual ~Interface (); /** * Execute this assembler object. This function performs the primary work @@ -504,7 +502,7 @@ namespace aspect virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, - internal::Assembly::CopyData::CopyDataBase &data) const =0; + internal::Assembly::CopyData::CopyDataBase &data) const = 0; /** * This function gets called if a MaterialModelOutputs is created @@ -539,7 +537,7 @@ namespace aspect * This ensures the additional material model output is available when * execute() is called. */ - virtual void create_additional_material_model_outputs(MaterialModel::MaterialModelOutputs &) const {} + virtual void create_additional_material_model_outputs(MaterialModel::MaterialModelOutputs &) const; /** * A required function for objects that implement the assembly of terms @@ -551,16 +549,12 @@ namespace aspect * equation). Thus different objects compute different residuals (i.e. * the residual for a melt advection equation looks different from the * residual for a passive compositional field). + * For assemblers for the Stokes system, an implementation of this + * function is not necessary. */ virtual std::vector - compute_residual(internal::Assembly::Scratch::ScratchBase &) const - { - AssertThrow(false, ExcMessage("This function should either be implemented " - "(if this is an assembler that has to compute a residual, or not be called " - "(if this is an assembler that has not to compute a residual).")); - return std::vector(); - } + compute_residual(internal::Assembly::Scratch::ScratchBase &) const; }; /** diff --git a/include/aspect/simulator/assemblers/stokes.h b/include/aspect/simulator/assemblers/stokes.h index f87632b853f..5e13ff279a0 100644 --- a/include/aspect/simulator/assemblers/stokes.h +++ b/include/aspect/simulator/assemblers/stokes.h @@ -37,8 +37,6 @@ namespace aspect public SimulatorAccess { public: - virtual ~StokesPreconditioner () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, @@ -54,8 +52,6 @@ namespace aspect public SimulatorAccess { public: - virtual ~StokesCompressiblePreconditioner () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, @@ -71,8 +67,6 @@ namespace aspect public SimulatorAccess { public: - virtual ~StokesIncompressibleTerms () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, @@ -93,8 +87,6 @@ namespace aspect public SimulatorAccess { public: - virtual ~StokesCompressibleStrainRateViscosityTerm () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, @@ -115,8 +107,6 @@ namespace aspect public SimulatorAccess { public: - virtual ~StokesReferenceDensityCompressibilityTerm () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, @@ -137,8 +127,6 @@ namespace aspect public SimulatorAccess { public: - virtual ~StokesImplicitReferenceDensityCompressibilityTerm () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, @@ -159,8 +147,6 @@ namespace aspect public SimulatorAccess { public: - virtual ~StokesIsothermalCompressionTerm () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, @@ -176,8 +162,6 @@ namespace aspect public SimulatorAccess { public: - virtual ~StokesBoundaryTraction () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, @@ -196,8 +180,6 @@ namespace aspect public SimulatorAccess { public: - virtual ~StokesPressureRHSCompatibilityModification () {}; - virtual void execute(internal::Assembly::Scratch::ScratchBase &scratch, diff --git a/include/aspect/simulator_access.h b/include/aspect/simulator_access.h index 7e5bd975839..2d3129b3141 100644 --- a/include/aspect/simulator_access.h +++ b/include/aspect/simulator_access.h @@ -640,8 +640,8 @@ namespace aspect get_newton_handler () const; /** - * Return a set of boundary indicators that describes which of the - * boundaries have a free surface boundary condition + * Return a reference to the free surface handler. This function will + * throw an exception if no free surface is activated. */ const FreeSurfaceHandler & get_free_surface_handler () const; diff --git a/source/simulator/assemblers/interface.cc b/source/simulator/assemblers/interface.cc index 887c8cd5854..d9d6afb5c8c 100644 --- a/source/simulator/assemblers/interface.cc +++ b/source/simulator/assemblers/interface.cc @@ -461,6 +461,33 @@ namespace aspect namespace Assemblers { + template + Interface::~Interface() + {} + + + + template + void + Interface::create_additional_material_model_outputs(MaterialModel::MaterialModelOutputs &) const + {} + + + + template + std::vector + Interface::compute_residual(internal::Assembly::Scratch::ScratchBase &) const + { + AssertThrow(false, + ExcMessage("If this is an assembler that has to compute a residual" + "then this function should be implemented. " + "If this is an assembler that does not have to compute a residual, it should not be called.")); + + return std::vector(); + } + + + template Manager::Properties::Properties () : @@ -492,7 +519,8 @@ namespace aspect } \ } \ namespace Assemblers { \ - template struct Manager::Properties; \ + template class Interface; \ + template class Manager; \ } ASPECT_INSTANTIATE(INSTANTIATE) } diff --git a/source/simulator/assemblers/newton_stokes.cc b/source/simulator/assemblers/newton_stokes.cc index b2912010d94..df0a0eaad84 100644 --- a/source/simulator/assemblers/newton_stokes.cc +++ b/source/simulator/assemblers/newton_stokes.cc @@ -584,6 +584,7 @@ namespace aspect namespace Assemblers { #define INSTANTIATE(dim) \ + template class NewtonInterface; \ template class NewtonStokesPreconditioner; \ template class NewtonStokesIncompressibleTerms; \ template class NewtonStokesCompressibleStrainRateViscosityTerm; \ diff --git a/source/simulator/assembly.cc b/source/simulator/assembly.cc index 6e5bea30a1f..fe8573601e0 100644 --- a/source/simulator/assembly.cc +++ b/source/simulator/assembly.cc @@ -109,7 +109,7 @@ namespace aspect // lines in set_assemblers(), where this operation appears multiple times. template void - initialize_simulator(Simulator &simulator, + initialize_simulator(const Simulator &simulator, std::vector > &assemblers) { for (unsigned int i=0; iadvection_system.size(); ++i) { - std::vector new_residual = assemblers->advection_system[i]->compute_residual(scratch); - for (unsigned int i=0; i new_residual = assemblers->advection_system[i]->compute_residual(scratch); + for (unsigned int j=0; j; \ template class MeltStokesPreconditioner; \ template class MeltStokesSystem; \ template class MeltStokesSystemBoundary; \ diff --git a/source/simulator/simulator_access.cc b/source/simulator/simulator_access.cc index b8a9b7f7786..03ab1a16a6e 100644 --- a/source/simulator/simulator_access.cc +++ b/source/simulator/simulator_access.cc @@ -565,6 +565,7 @@ namespace aspect { Assert (simulator->free_surface.get() != 0, ExcMessage("You can not call this function if the free surface is not enabled.")); + return *(simulator->free_surface); }