From 41e08ccb94fa46ce1497251b5478c8a6e8ccd973 Mon Sep 17 00:00:00 2001 From: Abelin Kameni <abelin.kameni@lgep.supelec.fr> Date: Fri, 5 Mar 2010 11:20:35 +0000 Subject: [PATCH] Transform the nodal values --- Solver/dgTransformNodalValue.cpp | 87 ++++++++++++++++++++++++++++++++ Solver/dgTransformNodalValue.h | 30 +++++++++++ 2 files changed, 117 insertions(+) create mode 100644 Solver/dgTransformNodalValue.cpp create mode 100644 Solver/dgTransformNodalValue.h diff --git a/Solver/dgTransformNodalValue.cpp b/Solver/dgTransformNodalValue.cpp new file mode 100644 index 0000000000..a590808a4f --- /dev/null +++ b/Solver/dgTransformNodalValue.cpp @@ -0,0 +1,87 @@ +#include "dgTransformNodalValue.h" +#include "dgGroupOfElements.h" +#include "dgSystemOfEquations.h" +#include "function.h" + +//---------------------------------------------------------------------------------- +static double n_supra = 20; + +int dgSupraTransformNodalValue::apply ( dgDofContainer *solution) +{ + dgGroupCollection *groups=solution->getGroups(); + int nbFields =_claw->getNbFields(); + + + for (int iGroup=0 ; iGroup<groups->getNbElementGroups() ; iGroup++) { + dgGroupOfElements &group = *groups->getElementGroup(iGroup); + fullMatrix<double> &sol = solution->getGroupProxy(iGroup); + fullMatrix<double> Temp; + for (int iElement=0 ; iElement<group.getNbElements() ; ++iElement) { + Temp.setAsProxy(sol, nbFields*iElement, nbFields ); + int fSize = Temp.size1(); + for (int k=0; k<nbFields; ++k) { + + for (int i=0; i<fSize; ++i) { + if (Temp(i,k)<0) Temp(i,k) = - pow(fabs(Temp(i,k)),1/n_supra); + else Temp(i,k) = pow(fabs(Temp(i,k)),1/n_supra); + // Temp(i,k) = Temp(i,k)*0.5; + } + + } + } + } + +} + +int dgSupraTransformNodalValue::apply_Inverse ( dgDofContainer *solution) +{ + dgGroupCollection *groups=solution->getGroups(); + int nbFields =_claw->getNbFields(); + for (int iGroup=0 ; iGroup<groups->getNbElementGroups() ; iGroup++) { + dgGroupOfElements &group = *groups->getElementGroup(iGroup); + fullMatrix<double> &sol = solution->getGroupProxy(iGroup); + fullMatrix<double> Temp; + for (int iElement=0 ; iElement<group.getNbElements() ; ++iElement) { + Temp.setAsProxy(sol, nbFields*iElement, nbFields ); + int fSize = Temp.size1(); + for (int k=0; k<nbFields; ++k) { + + + for (int i=0; i<fSize; ++i) { + if (Temp(i,k)<0) Temp(i,k) =- pow(fabs(Temp(i,k)),n_supra); + else Temp(i,k) = pow(fabs(Temp(i,k)),n_supra); + //Temp(i,k) = 2*Temp(i,k); + + } + + } + } + } +} + + +#include "Bindings.h" + +void dgTransformNodalValue::registerBindings(binding *b) { + classBinding *cb = b->addClass<dgTransformNodalValue>("dgTransformNodalValue"); + cb->setDescription("Parent class for transformations of nodal value"); + methodBinding *cm; + cm = cb->addMethod("apply",&dgTransformNodalValue::apply); + cm->setArgNames("solution",NULL); + cm->setDescription("apply a transformation of the solution"); + + cm = cb->addMethod("apply_Inverse",&dgTransformNodalValue::apply_Inverse); + cm->setArgNames("solution",NULL); + cm->setDescription("apply an inverse transformation of the solution"); +} + +void dgSupraTransformNodalValueRegisterBindings(binding *b) { + classBinding *cb = b->addClass<dgSupraTransformNodalValue>("dgSupraTransformNodalValue"); + cb->setDescription("Transformation of nodal value with the power law of superconductors"); + methodBinding *cm; + cm = cb->setConstructor<dgSupraTransformNodalValue,dgConservationLaw *>(); + cm->setDescription("exemple"); + cm->setArgNames("law",NULL); + cb->setParentClass<dgTransformNodalValue>(); +} + diff --git a/Solver/dgTransformNodalValue.h b/Solver/dgTransformNodalValue.h new file mode 100644 index 0000000000..cdc62f06de --- /dev/null +++ b/Solver/dgTransformNodalValue.h @@ -0,0 +1,30 @@ +#ifndef _DG_TRANSFORM_NODAL_VALUE_H_ +#define _DG_TRANSFORM_NODAL_VALUE_H_ + +#include "fullMatrix.h" +#include <vector> +class dgDofContainer; +class dgGroupCollection; +class dgConservationLaw; +class binding; + +class dgTransformNodalValue{ +protected: + dgConservationLaw *_claw; +public: + dgTransformNodalValue (dgConservationLaw *claw) : _claw(claw) {} + virtual int apply ( dgDofContainer *sol)=0; + virtual int apply_Inverse ( dgDofContainer *sol)=0; + static void registerBindings(binding *b); +}; + +class dgSupraTransformNodalValue : public dgTransformNodalValue{ +public : + dgSupraTransformNodalValue (dgConservationLaw *claw) : dgTransformNodalValue (claw) {} + virtual int apply ( dgDofContainer *solution); + virtual int apply_Inverse ( dgDofContainer *solution); +}; +void dgSupraTransformNodalValueRegisterBindings(binding *b); + + +#endif -- GitLab