1
+ // ****************************************************************
2
+ // * This file is part of the AsFem framework
3
+ // * A Simple Finite Element Method program (AsFem)
4
+ // * All rights reserved, Yang Bai/M3 Group@CopyRight 2020-present
5
+ // * https://github.com/M3Group/AsFem
6
+ // * Licensed under GNU GPLv3, please see LICENSE for details
7
+ // * https://www.gnu.org/licenses/gpl-3.0.en.html
8
+ // ****************************************************************
9
+ // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10
+ // +++ Author : Yang Bai
11
+ // +++ Date : 2022.08.26
12
+ // +++ Purpose: Calculate the material properties required by diffusion
13
+ // +++ element. In this code, we can define:
14
+ // +++ 1) D
15
+ // +++ 2) dD/dc
16
+ // +++ Standard benchmark test for 2d nonlinear diffusion equation
17
+ // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
18
+
19
+ #include " MateSystem/User1Material.h"
20
+
21
+ User1Material::User1Material (){
22
+ srand (time (00 ));// for random seed
23
+ }
24
+ void User1Material::initMaterialProperties (const nlohmann::json &inputparams,
25
+ const LocalElmtInfo &elmtinfo,
26
+ const LocalElmtSolution &elmtsoln,
27
+ MaterialsContainer &mate){
28
+ // ***************************************************
29
+ // *** get rid of unused warning
30
+ // ***************************************************
31
+ if (inputparams.size ()||elmtinfo.m_dt ||elmtsoln.m_gpU [0 ]||mate.getScalarMaterialsNum ()){}
32
+
33
+ }
34
+
35
+ // ********************************************************************
36
+ void User1Material::computeMaterialProperties (const nlohmann::json &inputparams,
37
+ const LocalElmtInfo &elmtinfo,
38
+ const LocalElmtSolution &elmtsoln,
39
+ const MaterialsContainer &mateold,
40
+ MaterialsContainer &mate){
41
+ // **************************************************************
42
+ // *** get rid of unused warning
43
+ // **************************************************************
44
+ if (inputparams.size ()||elmtinfo.m_dt ||elmtsoln.m_gpU [0 ]||
45
+ mateold.getScalarMaterialsNum ()||mate.getScalarMaterialsNum ()){}
46
+
47
+ // ************************
48
+ // *** here the poisson equation is:
49
+ // *** div(sigma*grad(phi))=F
50
+ mate.ScalarMaterial (" sigma" )=JsonUtils::getValue (inputparams," sigma" );// sigma
51
+ mate.ScalarMaterial (" dsigmadu" )=0.0 ;// dsigma/dphi
52
+ mate.ScalarMaterial (" f" )=JsonUtils::getValue (inputparams," f" );// F
53
+ mate.ScalarMaterial (" dfdu" )=0.0 ;// dF/dphi
54
+ mate.VectorMaterial (" gradu" )=elmtsoln.m_gpGradU [1 ];// the gradient of u
55
+
56
+ mate.ScalarMaterial (" myx" )=1.0 *rand ()/RAND_MAX;
57
+ if (elmtinfo.m_elmtid ==elmtinfo.m_elmtsnum ){
58
+ if (elmtinfo.m_qpointid ==elmtinfo.m_qpointsnum ){
59
+ mate.ScalarMaterial (" myx" )=1000.0 ;
60
+ }
61
+ }
62
+
63
+ }
0 commit comments